mailsuite 2.2.1__tar.gz → 2.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -109,6 +109,4 @@ venv.bak/
109
109
  private/
110
110
  *.eml
111
111
  *.msg
112
- # Sanitized sample messages used as test fixtures are tracked despite *.eml
113
- !samples/failure_report_samples/*.eml
114
112
  scratch.py
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mailsuite
3
- Version: 2.2.1
3
+ Version: 2.2.2
4
4
  Summary: A Python package for retrieving, parsing, and sending emails
5
5
  Project-URL: Homepage, https://github.com/seanthegeek/mailsuite/
6
6
  Project-URL: Documentation, https://seanthegeek.github.io/mailsuite/
@@ -1,3 +1,3 @@
1
1
  """A Python package to simplify receiving, parsing, and sending email"""
2
2
 
3
- __version__ = "2.2.1"
3
+ __version__ = "2.2.2"
@@ -96,13 +96,17 @@ class IMAPClient(imapclient.IMAPClient):
96
96
  return result.decode("utf-8", "replace")
97
97
  return str(result)
98
98
 
99
- def _start_idle(self, idle_callback, idle_timeout: int = 30):
99
+ def _start_idle(self, idle_callback, idle_timeout: int = 30, config_reloading=None):
100
100
  """
101
101
  Starts an IMAP IDLE session
102
102
 
103
103
  Args:
104
104
  idle_callback: A callback function
105
105
  idle_timeout: Number of seconds to wait for an IDLE response
106
+ config_reloading: Optional zero-arg callable; when it returns a
107
+ truthy value the IDLE loop exits cleanly so the caller can
108
+ reload config or shut down. Checked at the top of each cycle,
109
+ while IDLE is active, so idle_done() stays valid.
106
110
  """
107
111
  if self._idle_supported is False:
108
112
  raise imapclient.exceptions.IMAPClientError(
@@ -115,6 +119,8 @@ class IMAPClient(imapclient.IMAPClient):
115
119
  # re-arms this loop in place instead of starting a nested IDLE loop.
116
120
  self._idle_running = True
117
121
  while True:
122
+ if config_reloading and config_reloading():
123
+ break
118
124
  try:
119
125
  # Refresh the IDLE session every 5 minutes to stay connected
120
126
  if time.monotonic() - idle_start_time > 5 * 60:
@@ -183,6 +189,7 @@ class IMAPClient(imapclient.IMAPClient):
183
189
  oauth2_token_provider: Optional[Callable[[], str]] = None,
184
190
  oauth2_mechanism: str = "XOAUTH2",
185
191
  oauth2_vendor: Optional[str] = None,
192
+ config_reloading: Optional[Callable[[], bool]] = None,
186
193
  ):
187
194
  """
188
195
  Connects to an IMAP server
@@ -339,7 +346,11 @@ class IMAPClient(imapclient.IMAPClient):
339
346
  # reset_connection() re-runs __init__ from inside the loop, and a
340
347
  # nested _start_idle would stack IDLE loops on every reconnect.
341
348
  if idle_callback is not None and not getattr(self, "_idle_running", False):
342
- self._start_idle(idle_callback, idle_timeout=idle_timeout)
349
+ self._start_idle(
350
+ idle_callback,
351
+ idle_timeout=idle_timeout,
352
+ config_reloading=config_reloading,
353
+ )
343
354
 
344
355
  def reset_connection(self):
345
356
  """Resets the connection to the IMAP server"""
@@ -174,6 +174,7 @@ class IMAPConnection(MailboxConnection):
174
174
  oauth2_token_provider=self._oauth2_token_provider,
175
175
  oauth2_mechanism=self._oauth2_mechanism,
176
176
  oauth2_vendor=self._oauth2_vendor,
177
+ config_reloading=config_reloading,
177
178
  )
178
179
  except (timeout, IMAPClientError):
179
180
  logger.warning("IMAP connection timeout. Reconnecting...")
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes