Active waiting?
Sebastian Spaeth
Sebastian at SSpaeth.de
Mon Mar 23 16:00:41 GMT 2015
Am 23.03.2015 um 15:53 schrieb Nicolas Sebrecht:
> On Mon, Mar 23, 2015 at 01:01:12PM +0100, Alvaro Gamez wrote:
>> What a pity :(
>> If there's anything I can research on this to improve offlineimap
>> please let me know in which direction.
>
> This is a known issue but nobody looked into this deeply.
>
> https://github.com/OfflineIMAP/offlineimap/issues/81
>
> We need to know which Python code is to blame, whether it's in a library
> or in our code. With more information we will clearly see if we can do
> something or not.
Actually, yes, I did look into this previously :-). I added a comment to
issue 81 to provide a tad more detail. My research is from a few years
back and I am writing from memory.
Thing is, that our main thread needs to wait for it's daughter threads
to exit. This is in threadutils.py:exitnotifymonitorloop.
We use a Queue in which all exiting threads are put() and loop around,
waiting with .get(60) for one of those threads to finish.
Queue().get(60) will wakeup every 50ms or so to see if the condition has
been fulfilled. If you do not specify a timeout, there will be no
wakeups, but the main thread will also not listen (and react) to
signals, such as sent by CTRL-C (or SIGTERM). So we would run danger of
hanging indefinitely and not be able to react on Ctrl-C.
So if you find a solution that lets us wait for daughter threads and
reacts to Ctrl-C (and other signals), we are gold. Unfortunately, I
failed to find such a solution. (by, this is related to
http://bugs.python.org/issue1360).
The good news is that the signal issue seems to have been solved in
python3 (according to the upstream bug report), so we are using python3,
we should be able to use that code without any timeout, and save lots of
wakeups. (untested).
Sebastian
More information about the OfflineIMAP-project
mailing list