Skip to content

Commit

Permalink
Log polling statement every 5 minutes to cut down on logging volume (#17
Browse files Browse the repository at this point in the history
)

* Log polling statement every 5 minutes to cut down on logging volume
  • Loading branch information
jkemp101 committed Jul 30, 2020
1 parent 5b937e7 commit e37f19a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion inbox/mailsync/backends/imap/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
from gevent import Greenlet
import gevent
import imaplib
import time
from sqlalchemy import func
from sqlalchemy.orm import load_only
from sqlalchemy.exc import IntegrityError
Expand Down Expand Up @@ -148,6 +149,7 @@ def __init__(self, account_id, namespace_id, folder_name,
self.last_fast_refresh = None
self.flags_fetch_results = {}
self.conn_pool = connection_pool(self.account_id)
self.polling_logged_at = 0

self.state_handlers = {
'initial': self.initial_sync,
Expand Down Expand Up @@ -343,7 +345,12 @@ def initial_sync(self):
@retry_crispin
def poll(self):
log.bind(state='poll')
log.debug('polling')
# Only log every 5 minutes to cut down on the volume of
# this log statement
timestamp = time.time()
if timestamp - self.polling_logged_at > 60 * 5:
self.polling_logged_at = timestamp
log.debug('polling')
self.poll_impl()
return 'poll'

Expand Down

0 comments on commit e37f19a

Please sign in to comment.