本文整理汇总了Python中dart.client.python.dart_client.Dart.get_subscription_elements方法的典型用法代码示例。如果您正苦于以下问题:Python Dart.get_subscription_elements方法的具体用法?Python Dart.get_subscription_elements怎么用?Python Dart.get_subscription_elements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dart.client.python.dart_client.Dart
的用法示例。
在下文中一共展示了Dart.get_subscription_elements方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: NoOpEngine
# 需要导入模块: from dart.client.python.dart_client import Dart [as 别名]
# 或者: from dart.client.python.dart_client.Dart import get_subscription_elements [as 别名]
class NoOpEngine(object):
def __init__(self, region, dart_host='localhost', dart_port=5000, dart_api_version=1):
self.region = region
self.dart = Dart(dart_host, dart_port, dart_api_version)
def run(self):
action_context = self.dart.engine_action_checkout(os.environ.get('DART_ACTION_ID'))
action = action_context.action
datastore = action_context.datastore
state = ActionResultState.SUCCESS
error_message = None
try:
sleep_seconds = datastore.data.args['action_sleep_time_in_seconds']
_logger.info('sleeping for %s seconds...' % sleep_seconds)
time.sleep(sleep_seconds)
if action.data.action_type_name == NoOpActionTypes.action_that_fails.name:
state = ActionResultState.FAILURE
error_message = '%s failed as expected' % NoOpActionTypes.action_that_fails.name
if action.data.action_type_name == NoOpActionTypes.consume_subscription.name:
subscription_elements = self.dart.get_subscription_elements(action.id)
_logger.info('consuming subscription, size = %s' % len(list(subscription_elements)))
except Exception as e:
state = ActionResultState.FAILURE
error_message = e.message + '\n\n\n' + traceback.format_exc()
finally:
self.dart.engine_action_checkin(action.id, ActionResult(state, error_message))