[PATCH] Simplify exit thread evaluation

Leif Walsh leif.walsh at gmail.com
Wed Dec 1 16:12:27 GMT 2010


This may solve my deadlock issue from the other thread if it is correct.
I'll test it later, thanks.
On Dec 1, 2010 11:07 AM, "Sebastian Spaeth" <Sebastian at sspaeth.de> wrote:
> Rather than sleeping for 1 second and poll our exitthread Queue in a
> non-bloking fashion simply call it in a blocking fashion. Works for
> me, and is potentially somewhat faster as we don't do unnecessary
> sleeps after a thread exited.
>
> Signed-off-by: Sebastian Spaeth <Sebastian at SSpaeth.de>
> ---
> offlineimap/threadutil.py | 10 ++++------
> 1 files changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/offlineimap/threadutil.py b/offlineimap/threadutil.py
> index b516f68..579ef35 100644
> --- a/offlineimap/threadutil.py
> +++ b/offlineimap/threadutil.py
> @@ -111,12 +111,10 @@ def exitnotifymonitorloop(callback):
> the monitor will hold the lock all the while the other thread is waiting.
> """
> global exitthreads
> - while 1: # Loop forever.
> - try:
> - thrd = exitthreads.get(False)
> - callback(thrd)
> - except Empty:
> - time.sleep(1)
> + while 1:
> + # Loop forever and call 'callback' for each thread that exited
> + thrd = exitthreads.get(True)
> + callback(thrd)
>
> def threadexited(thread):
> """Called when a thread exits."""
> --
> 1.7.1
>
>
> _______________________________________________
> OfflineIMAP-project mailing list
> OfflineIMAP-project at lists.alioth.debian.org
> http://lists.alioth.debian.org/mailman/listinfo/offlineimap-project
>
> OfflineIMAP homepage: http://software.complete.org/offlineimap
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/offlineimap-project/attachments/20101201/0ed49a6d/attachment-0001.html>


More information about the OfflineIMAP-project mailing list