eliminiated redunant call and tuned connection timing
This commit is contained in:
parent
309fc7e3c5
commit
5ba5765435
1 changed files with 6 additions and 6 deletions
|
@ -17,6 +17,7 @@ class ChannelMonitor(threading.Thread):
|
|||
|
||||
def __init__(self):
|
||||
threading.Thread.__init__(self)
|
||||
self.pnut = Pnut(app.config['MATRIX_PNUT_TOKEN'])
|
||||
self.matrix_api_url = app.config['MATRIX_HOST'] + '/_matrix/client/r0'
|
||||
self.matrix_api_token = app.config['MATRIX_AS_TOKEN']
|
||||
self.txId = 0
|
||||
|
@ -108,8 +109,7 @@ class ChannelMonitor(threading.Thread):
|
|||
|
||||
def poll_channel(self, room):
|
||||
try:
|
||||
r = Pnut(app.config['MATRIX_PNUT_TOKEN']).get_channel_stream(room.pnut_chan, room.pnut_since)
|
||||
if r.headers['X-RateLimit-Remaining'] < 40:
|
||||
r = self.pnut.get_channel_stream(room.pnut_chan, room.pnut_since)
|
||||
print(r.headers['X-RateLimit-Remaining'], r.headers['X-RateLimit-Reset'])
|
||||
except requests.exceptions.ConnectionError:
|
||||
logging.info('*** Problem connecting to pnut.io! Waiting to retry. ***')
|
||||
|
@ -189,8 +189,8 @@ class ChannelMonitor(threading.Thread):
|
|||
rooms = MatrixRoom2.query.all()
|
||||
for r in rooms:
|
||||
self.poll_channel(r)
|
||||
time.sleep(1)
|
||||
time.sleep(1.5)
|
||||
time.sleep(.25)
|
||||
time.sleep(3)
|
||||
logging.info("-- Stopping channel monitor --")
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Reference in a new issue