<DKIM> [PATCH] add repository retrycount option

Nicolas Sebrecht nicolas.s-dev at laposte.net
Mon Dec 19 11:55:11 UTC 2016


On Mon, Dec 19, 2016 at 05:31:35AM +0000, lkcl wrote:
> From 81205e3bb3bc04008b9473a71b90ec9a0612762c Mon Sep 17 00:00:00 2001
> From: Luke Kenneth Casson Leighton <lkcl at lkcl.net>
> Date: Mon, 19 Dec 2016 05:29:24 +0000
> Subject: [PATCH] add repository retrycount option
> 
> Signed-off-by: Luke Kenneth Casson Leighton <lkcl at lkcl.net>
> ---
>  offlineimap.conf            | 21 +++++++++++++++++++++
>  offlineimap/folder/Gmail.py |  2 +-
>  offlineimap/folder/IMAP.py  |  5 ++++-
>  3 files changed, 26 insertions(+), 2 deletions(-)
> 
> diff --git a/offlineimap.conf b/offlineimap.conf
> index 4df674b..2813061 100644
> --- a/offlineimap.conf
> +++ b/offlineimap.conf
> @@ -1272,6 +1272,27 @@ remoteuser = username
>  
>  # This option stands in the [Repository RemoteExample] section.
>  #
> +# Operating under extreme network conditions (China) network connectivity
> +# especially for SSL can be so bad and so slow that absolutely every
> +# possible kind of connectivity error that can occur does occur.
> +#
> +# Rather than have offlineimap exit on errors it may be preferable
> +# to have it simply retry connections dozens of times.  The alternative

s/connections/fetching of messages/

> +# is to restart offlineimap in a constant loop, which may involve using
> +# significant CPU cycles (if the repository is large) to load up the
> +# UID database again.
> +#
> +# This option is best utilised in combination with socktimeout, which
> +# catches instances of interference by e.g. the GFW at the TCP layer,
> +# as well as China ISPs simply not coping.
> +#
> +# Default value: retrycount = 2
> +#
> +#retrycount = 2
> +
> +
> +# This option stands in the [Repository RemoteExample] section.
> +#
>  # If offlineiamp is having troubles to download some UIDS, it's possible to get
>  # them ignored in a list. This only ignore the download.
>  #
> diff --git a/offlineimap/folder/Gmail.py b/offlineimap/folder/Gmail.py
> index 31eaeb3..dc594d1 100644
> --- a/offlineimap/folder/Gmail.py
> +++ b/offlineimap/folder/Gmail.py
> @@ -71,7 +71,7 @@ class GmailFolder(IMAPFolder):
>                    (probably severity MESSAGE) if e.g. no message with
>                    this UID could be found.
>          """
> -        data = self._fetch_from_imap(str(uid), 2)
> +        data = self._fetch_from_imap(str(uid), self.retrycount)
>  
>          # data looks now e.g.
>          #[('320 (X-GM-LABELS (...) UID 17061 BODY[] {2565}','msgbody....')]
> diff --git a/offlineimap/folder/IMAP.py b/offlineimap/folder/IMAP.py
> index f8fcf7b..6587b8a 100644
> --- a/offlineimap/folder/IMAP.py
> +++ b/offlineimap/folder/IMAP.py
> @@ -55,6 +55,9 @@ class IMAPFolder(BaseFolder):
>          # self.ui is set in BaseFolder.
>          self.imap_query = ['BODY.PEEK[]']
>  
> +        # number of times to retry fetching messages
> +        self.retrycount = int(self.repository.getconf('retry', '2'))

self.retrycount = self.repository.getconfint('retrycount', 2)

We have getconfint() and the option name does not match.

> +
>          fh_conf = self.repository.account.getconf('filterheaders', '')
>          self.filterheaders = [h for h in re.split(r'\s*,\s*', fh_conf) if h]
>  
> @@ -305,7 +308,7 @@ class IMAPFolder(BaseFolder):
>                    this UID could be found.
>          """
>  
> -        data = self._fetch_from_imap(str(uid), 2)
> +        data = self._fetch_from_imap(str(uid), self.retrycount)
>  
>          # Data looks now e.g.
>          # [('320 (UID 17061 BODY[] {2565}','msgbody....')]

Applied with the above fixes and some minor tuning of the commit
message.

Thank you!

-- 
Nicolas Sebrecht



More information about the OfflineIMAP-project mailing list