adjust connection rate

This commit is contained in:
Morgan McMillian 2017-07-27 20:50:27 -07:00
parent 0201c904fa
commit 836ae979cb

View file

@ -109,6 +109,7 @@ class ChannelMonitor(threading.Thread):
def poll_channel(self, room): def poll_channel(self, room):
try: try:
r = Pnut(app.config['MATRIX_PNUT_TOKEN']).get_channel_stream(room.pnut_chan, room.pnut_since) r = Pnut(app.config['MATRIX_PNUT_TOKEN']).get_channel_stream(room.pnut_chan, room.pnut_since)
# print(r.headers['X-RateLimit-Remaining'], r.headers['X-RateLimit-Reset'])
except requests.exceptions.ConnectionError: except requests.exceptions.ConnectionError:
logging.info('*** Problem connecting to pnut.io! Waiting to retry. ***') logging.info('*** Problem connecting to pnut.io! Waiting to retry. ***')
time.sleep(30) time.sleep(30)
@ -187,7 +188,8 @@ class ChannelMonitor(threading.Thread):
rooms = MatrixRoom2.query.all() rooms = MatrixRoom2.query.all()
for r in rooms: for r in rooms:
self.poll_channel(r) self.poll_channel(r)
time.sleep(15) time.sleep(1)
time.sleep(1.5)
logging.info("-- Stopping channel monitor --") logging.info("-- Stopping channel monitor --")
if __name__ == '__main__': if __name__ == '__main__':