def requestThread(): LATEST = None while True: try: LATEST = mainRequest(LATEST) except: Log.write_traceback_error('Error while requesting file') finally: time.sleep(Config.backup.interval)
def get_from_telegram_server(): offset = None # running offset allowed_upd = allowed_updates while 1: try: result = self.getUpdates(offset=offset, timeout=timeout, allowed_updates=allowed_upd) allowed_upd = None if len(result) > 0: offset = max( [relay_to_collector(update) for update in result]) + 1 except telepot.exception.BadHTTPResponse as e: Log.write_traceback_error( 'Catched telepot.exception.BadHTTPResponse') if e.status == 502: time.sleep(30) except urllib3.exceptions.ReadTimeoutError: Log.write_traceback_error( 'Catched requests.exceptions.ReadTimeoutError') except telepot.exception.TelegramError as e: Log.write_traceback_error( 'Catched telepot.exception.TelegramError (code = %d)' % e[1]) except urllib3.exceptions.ProtocolError: Log.write_traceback_error( 'Catched urllib3.exceptions.ProtocolError') except: traceback.print_exc() finally: time.sleep(relax)