[PATCH] Re: Remove weird SigListener class

Nicolas Sebrecht nicolas.s-dev at laposte.net
Sun May 8 13:28:40 BST 2011


On Sat, May 07, 2011 at 05:40:32PM +0200, Sebastian Spaeth wrote:
> 
> The SigListener class was used to queue folders that we need to sync and
> to receive "resync" and "abort" signals. It was undocumented and weird
> and we had to pass "siglisteners" through the whole program.
> 
> Simply do away with it, and make 2 functions in the Account() class:
> set_abort_event and get_abort_event which can be used to set and check
> for such signals. This way we do not need to pass siglisteners all over
> the place. Tested Blinkenlights and TTYUI uis to make sure that SIGUSR1
> and SIGUSR2 actually still work.
> 
> Document those signals in MANUAL.rst. They were completly undocumented.

Very appreciated.

> This simplifies the code and interdependencies by passing less stuff
> around. Removes an undocumented and weirdly named class.
> 
> Signed-off-by: Sebastian Spaeth <Sebastian at SSpaeth.de>
> 
> ---
> Really, had *ANYONE* really understood what the completly undocumented
> SigListener class was doing?

Actually this class made always me feel "don't worry about that,
OfflineIMAP work".

>                              It was first and foremost used as a
> FolderQueue, but then it would also be send signals. We can really do
> away with a Queue() for folders, we can simply iterate through them as
> we get a nice iterator back from getfolders() anyway.
> 
> Signals are now sent to the Accout() class and that deals with either
> aborting sleep or aborting the autorefresh mode. Those signals were
> completely undocumented so I added documentation for them too.
> 
> Despite me adding lots of code documentation to places, this patch saves
> us 40 lines of code overall.

Looks OK.

> This is the last big patch that I sent, so that Ethan can then focus
> on the IDLE integration.

Someone told me he already heard that during last days. :-)

>  docs/MANUAL.rst                 |   13 +++
>  offlineimap/accounts.py         |  195 ++++++++++++++++----------------------
>  offlineimap/init.py             |   37 +++-----
>  offlineimap/syncmaster.py       |   14 +--
>  offlineimap/threadutil.py       |    4 -
>  offlineimap/ui/Blinkenlights.py |    4 +-
>  offlineimap/ui/Curses.py        |    4 +-
>  offlineimap/ui/UIBase.py        |   22 ++---
>  8 files changed, 127 insertions(+), 166 deletions(-)
> 
> diff --git a/docs/MANUAL.rst b/docs/MANUAL.rst
> index 9ef4eea..77a90d7 100644
> --- a/docs/MANUAL.rst
> +++ b/docs/MANUAL.rst
> @@ -262,6 +262,19 @@ MachineUI generates output in a machine-parsable format.  It is designed
>  for other programs that will interface to OfflineIMAP.
>  
>  
> +Signals
> +=======
> +
> +OfflineImap listens to the unix signals SIGUSR1 and SIGUSR2. If sent a

Look nicer with a newline and a blank line before the second sentence.
No need a resend.

Actually, this is the only thing I could find while reviewing this
topic.

> +SIGUSR1 it will abort any current (or next future) sleep of all accounts
> +that are configured to "autorefresh". In effect, this will trigger a
> +full sync of all accounts to be performed as soon as possible.
> +
> +If sent a SIGUSR2, it will stop "autorefresh mode" for all
> +accounts. That is, accounts will abort any current sleep and will exit
> +after a currently running synchronization has finished. This signal can
> +be used to gracefully exit out of a running offlineimap "daemon".
> +
>  KNOWN BUGS
>  ==========

Topic applied.

-- 
Nicolas Sebrecht




More information about the OfflineIMAP-project mailing list