mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-14 02:27:06 +01:00
Consumer loop: make sleep duration dynamic
Make the sleep duration dynamic to account for the time spent in loop_step. This improves responsiveness when repeatedly consuming newly arriving docs. Use float epoch seconds (time.time()) as the time type for MailFetcher.last_checked to allow for natural time arithmetic.
This commit is contained in:
parent
bd75a65866
commit
7357471b9e
2 changed files with 10 additions and 8 deletions
|
|
@ -161,7 +161,7 @@ class MailFetcher(Loggable):
|
|||
|
||||
self._enabled = bool(self._host)
|
||||
|
||||
self.last_checked = datetime.datetime.now()
|
||||
self.last_checked = time.time()
|
||||
self.consume = consume
|
||||
|
||||
def pull(self):
|
||||
|
|
@ -188,7 +188,7 @@ class MailFetcher(Loggable):
|
|||
f.write(message.attachment.data)
|
||||
os.utime(file_name, times=(t, t))
|
||||
|
||||
self.last_checked = datetime.datetime.now()
|
||||
self.last_checked = time.time()
|
||||
|
||||
def _get_messages(self):
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue