Normally I wouldn't pipe up here because threads really can be very tricky.  But check out:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/435883

I use this recipe, originally from "Python in a Nutshell", all the time, to solve exactly your problem.  Slow network stuff that I don't have to/want to babysit.

The recipe is well-commented, with an easy-to-follow usage example.  Basically though, Python's Queue module really takes away a lot of the trickiness here, acting as a thread-safe place to put jobs, and put results, without worrying about locks or sephamores or whatever it is people worry about.  And the callback functions you can pass in with the job may be all you really need to report success/failure of the jobs.

All in all, it's probably easier to just read the code.

Good luck.

On 10/4/05, Tim Rupp <[EMAIL PROTECTED]> wrote:
Hi list,

I'm trying to write a python script that uses ftplib to send items to a
local server I have. I want to be able to give ftplib a file to send,
and then just have it sort of go into the background and do its thing
while the script does other "stuff"

My attempts at it so far have caused the whole script to wait until the
ftp transfer finishes (essentially pausing the rest of the script).

Any ideas on how I can just make it go away, allowing me to do other
stuff like output various info? Can threads be used? If so, does anyone
have good resources to point me to for python threading?

Thanks in advance!
Tim
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to