Go to file
John Goerzen e1fb9492f8 Patch for signal handling to start a sync by Jim Pryor
Here's the way I'd like to use offlineimap on my laptop:
    1. Have a regular cron job running infrequently. The cron job
    checks to see
if I'm online, plugged in, and that no other copy of offlineimap is
running. If
all of these conditions are satisfied, it runs offlineimap just once:
"offlineimap -o -u Noninteractive.Quiet"

    2. When I start up mutt, I do it by calling a wrapper script that
    delays
until cron-started copies of offlineimap have finished, then starts
    offlineimap
on its regular, stay-alive and keep checking schedule. When I quit
    mutt, the
wrapper script tells offlineimap to stop.

This way I get frequent regular checks while I have mutt running, but
I don't
waste my battery/cpu checking frequently for mail when I'm not
interested in
it.

To make this work, though, it'd be nicer if it were easier to tell
offlineimap,
from the outside, things like "terminate cleanly now" and "when you've
finished
synching, then terminate instead of sleeping and synching again."

OK, to put my money where my mouth is, I attach two patches against
offlineimap
6.0.3.

The first, "cleanup.patch", cleans up a few spots that tend to throw
exceptions
for me as offlineimap is exiting from a KeyboardInterrupt.

The second adds signaling capabilities to offlineimap.

* sending a SIGTERM tells offlineimap to terminate immediately but
  cleanly,
  just as if "q" had been pressed in the GUI interface

* sending a SIGUSR1 tells every account to do a full sync asap: if
  it's
  sleeping, then wake up and do the sync now. If it's mid-sync, then
  re-synch
  any folders whose syncing has already been started or completed, and
  continue
  to synch the other, queued but not-yet-synched folders.

* sending a SIGHUP tells every account to die as soon as it can (but
  not
  immediately: only after finishing any synch it's now engaged in)

* sending a SIGUSR2 tells every account to do a full sync asap (as
  with
  SIGUSR1), then die

It's tricky to mix signals with threads, but I think I've done this
correctly.
I've been using it now for a few weeks without any obvious
problems. But I'm passing it
on so that others can review the code and test it out on their
systems. I developed the
patch when I was running Python 2.5.2, but to my knowledge I don't use
any Python 2.5-specific
code. Now I'm using the patch with Python 2.6.

Although I said "without any obvious problems," let me confess that
I'm
seeing offlineimap regularly choke when I do things like this: start
up
my offlineimap-wrapped copy of mutt, wait a while, put the machine to
sleep (not sure if offlineimap is active in the background or idling),
move to a different spot, wake the machine up again and it acquires a
new network, sometimes a wired network instead of wifi. Offlineimap
doesn't like that so much. I don't yet have any reason to think the
problems here come from my patches. But I'm just acknowledging them,
so
that if others are able to use offlineimap without any difficulty in
situations like I described, then maybe the fault is with my patches.
2008-12-01 16:13:16 -06:00
bin Prepping 6.0.3 2008-08-13 00:05:17 -05:00
debian Prepping 6.0.3 2008-08-13 00:05:17 -05:00
docs/sgml-common Step 2 of SVN to arch tree conversion 2005-04-16 20:33:35 +01:00
offlineimap Patch for signal handling to start a sync by Jim Pryor 2008-12-01 16:13:16 -06:00
.gitignore Add *~ to .gitignore 2008-03-12 00:29:31 -05:00
COPYING Update FSF address 2006-08-12 05:15:55 +01:00
COPYRIGHT Update for 5.99.7 2008-03-04 08:32:29 -06:00
FAQ.html Add the FAQ 2006-12-02 22:03:05 +01:00
Makefile Changed Makefile line to igonre .git instead of _darcs 2008-03-03 04:27:42 -06:00
offlineimap.conf New option to only work with subscribed folders 2008-10-01 00:33:57 -05:00
offlineimap.conf.minimal Step 2 of SVN to arch tree conversion 2005-04-16 20:33:35 +01:00
offlineimap.py Prepping 6.0.3 2008-08-13 00:05:17 -05:00
offlineimap.sgml Small doc grammar fix. fixes #74. 2008-06-11 15:27:03 -05:00
offlineimap.spec Updating version number to 4.0.16 2006-12-02 21:59:02 +01:00
README Updated copyright and version info for 4.0.15 2006-11-30 10:51:14 +01:00
setup.py Updated copyright and version info for 4.0.15 2006-11-30 10:51:14 +01:00
UPGRADING Step 2 of SVN to arch tree conversion 2005-04-16 20:33:35 +01:00

OfflineIMAP
Copyright (C) 2002 - 2006 John Goerzen <jgoerzen@complete.org>
This software comes with ABSOLUTELY NO WARRANTY; see the file
COPYING for details.  This is free software, and you are welcome
to distribute it under the conditions laid out in COPYING.

http://software.complete.org/offlineimap/

Please see manual.txt; the information previously in README has been moved
there.