Working threads progress
gervaz at gmail.com
Sat Oct 31 11:37:20 CET 2009
Il Wed, 28 Oct 2009 20:04:45 -0700, ryles ha scritto:
> On Oct 28, 7:02 pm, mattia <ger... at gmail.com> wrote:
>> Now, I would like to know the activity done (e.g. every two seconds) so
>> I create another thread that checks the queue size (using .qsize()).
>> Have you any suggestion to improve the code?
> It's not uncommon to pass each thread a second queue for output, which
> in your case might be tuples of (item, result). You can read from this
> queue in a single thread, and since the results now accumulate
> incrementally, you can easily collect more detailed status/progress
> information (if that's what you're looking for).
OK, but what do you mean by 'read from this queue'? I mean, I can have a
variable initialized when the working queue is full (e.g. ready to be
used) and then every time i use queue.get() decrement the variable (using
a lock in order to prevent concurrent access). Is what you had in mind?
More information about the Python-list