Thread Question

Simon Forman rogue_pedro at yahoo.com
Sat Aug 5 19:52:24 EDT 2006


Ritesh Raj Sarraf wrote:
> Bryan Olson on Saturday 05 Aug 2006 23:56 wrote:
>
> > You don't want "ziplock = threading.Lock()" in the body of
> > the function. It creates a new and different lock on every
> > execution. Your threads are all acquiring different locks.
> > To coordinate your threads, they need to be using the same
> > lock.
> >
> > Try moving "ziplock = threading.Lock()" out of the function, so
> > your code might read, in part:
> >
> >
> > ziplock = threading.Lock()
> >
> > def run(request, response, func=copy_first_match):
> > # And so on...
>
> Thanks. That did it. :-)
>
> Ritesh

Another thing you might want to consider would be to split your
download and zipping code into separate functions then create one more
thread to do all the zipping.  That way your downloading threads would
never be waiting around for each other to zip.


Just a thought.  :)
~Simon




More information about the Python-list mailing list