From 336b84436cc30a474e60bc3d78c3ed61dd516be8 Mon Sep 17 00:00:00 2001 From: Kylmakalle Date: Sun, 9 Jul 2017 14:48:31 +0300 Subject: [PATCH] Exceptions logging (debug) --- vk_messages.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/vk_messages.py b/vk_messages.py index aed8310..fb9566c 100644 --- a/vk_messages.py +++ b/vk_messages.py @@ -27,8 +27,7 @@ class VkPolling: if updates: handle_updates(vk_user, bot, chat_id, updates) except requests.exceptions.ReadTimeout as e: - print('Error', e) - print('Retrying VK Polling in {} seconds.'.format(int(timeout / 10))) + logging.warning('Retrying VK Polling in {} seconds.'.format(int(timeout / 10))) for i in range(timeout): if self._running: time.sleep(0.1) @@ -303,10 +302,10 @@ class VkMessage: api = vk.API(self.session) try: 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: timeout = 3 - print('Retrying getLongPollHistory in {} seconds'.format(timeout)) + logging.warning('Retrying getLongPollHistory in {} seconds'.format(timeout)) time.sleep(timeout) self.ts, self.pts = get_tses(self.session) ts_pts = ujson.dumps({"ts": self.ts, "pts": self.pts})