Exceptions logging (debug)

This commit is contained in:
Kylmakalle 2017-07-09 14:48:31 +03:00
parent 87af6c9b8d
commit 336b84436c

View File

@ -27,8 +27,7 @@ class VkPolling:
if updates: if updates:
handle_updates(vk_user, bot, chat_id, updates) handle_updates(vk_user, bot, chat_id, updates)
except requests.exceptions.ReadTimeout as e: except requests.exceptions.ReadTimeout as e:
print('Error', e) logging.warning('Retrying VK Polling in {} seconds.'.format(int(timeout / 10)))
print('Retrying VK Polling in {} seconds.'.format(int(timeout / 10)))
for i in range(timeout): for i in range(timeout):
if self._running: if self._running:
time.sleep(0.1) time.sleep(0.1)
@ -303,10 +302,10 @@ class VkMessage:
api = vk.API(self.session) api = vk.API(self.session)
try: try:
ts_pts = ujson.dumps({"ts": self.ts, "pts": self.pts}) ts_pts = ujson.dumps({"ts": self.ts, "pts": self.pts})
new = api.execute(code='return API.messages.getLongPollHistory({});'.format(ts_pts)) # api.messages.getLongPollHistory(ts=self.ts, pts=self.pts) new = api.execute(code='return API.messages.getLongPollHistory({});'.format(ts_pts))
except vk.api.VkAPIError: except vk.api.VkAPIError:
timeout = 3 timeout = 3
print('Retrying getLongPollHistory in {} seconds'.format(timeout)) logging.warning('Retrying getLongPollHistory in {} seconds'.format(timeout))
time.sleep(timeout) time.sleep(timeout)
self.ts, self.pts = get_tses(self.session) self.ts, self.pts = get_tses(self.session)
ts_pts = ujson.dumps({"ts": self.ts, "pts": self.pts}) ts_pts = ujson.dumps({"ts": self.ts, "pts": self.pts})