[Tutor] Trying to prevent ftplib from locking my script

Andrew P grouch at gmail.com
Tue Oct 4 23:26:25 CEST 2005

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


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

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 <caphrim007 at gmail.com> 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 at python.org
> http://mail.python.org/mailman/listinfo/tutor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20051004/9b55a93f/attachment.htm

More information about the Tutor mailing list