本文整理汇总了Python中error.Error.reset方法的典型用法代码示例。如果您正苦于以下问题:Python Error.reset方法的具体用法?Python Error.reset怎么用?Python Error.reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类error.Error
的用法示例。
在下文中一共展示了Error.reset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Exchange
# 需要导入模块: from error import Error [as 别名]
# 或者: from error.Error import reset [as 别名]
#.........这里部分代码省略.........
cls.normalise_assets()
cls.store_asset_pairs(asset_pairs)
except Exception as e:
cls._handle_discovery_error(str(e))
command.callback() # update the asset menus of all instances
@classmethod
def _handle_discovery_error(cls, msg):
logging.warning("Asset Discovery: " + msg)
##
# Start exchange
#
def start(self, error_refresh=None):
if not self.started:
self._check_price()
self.started = True
refresh = error_refresh if error_refresh else self.indicator.refresh_frequency
self.timeout_id = GLib.timeout_add_seconds(refresh, self._check_price)
return self
##
# Stop exchange, reset errors
#
def stop(self):
if self.timeout_id:
GLib.source_remove(self.timeout_id)
self.started = False
self.indicator.alarm.deactivate()
self.error.reset()
return self
##
# Restarts the exchange. This is necessary for restoring normal frequency as
# False must be returned for the restart operation to be done only once
#
def restart(self):
self.start()
return False
##
# This function is called frequently to get price updates from the API
#
def _check_price(self):
self.pair = self.asset_pair.get('pair')
timestamp = time.time()
command = DownloadCommand(self._get_ticker_url(), self.indicator.update_gui)
command.timestamp = timestamp
command.error = self._handle_error
command.validation = self.asset_pair
self.downloader.execute(command, self._handle_result)
logging.info('Request with TS: ' + str(timestamp))
if not self.error.is_ok():
self.timeout_id = None
return self.error.is_ok() # continues the timer if there are no errors
def _handle_error(self, error):
self.error.log(str(error))
self.error.increment()