def heartbeating_custom_error_activity(self, repeat_num): for i in range(repeat_num): time.sleep(0.2) try: get_context().heartbeat(str(i)) except CancellationError: raise MySpecialCancelledError("spam")
def filter(self, record): try: if self._filter_replaying and botoflow.get_context().replaying: return 0 except AttributeError: pass return 1
def _get_decision_context(self, calling_func): """Validates in decision context and returns it. :param calling_func: name of calling function :type calling_func: str :return: decision context :rtype: awsflow.context.DecisionContext :raises TypeError: if not in decision context """ context = None try: context = get_context() except AttributeError: # not in context pass if not isinstance(context, DecisionContext): raise TypeError("{}.{} can only be called in the decision " "context".format(self.__class__.__name__, calling_func)) return context
def perform_task(self, **kwargs): activity_context = get_context() task_token = activity_context.task.token with open('task_token.txt', 'w') as shared_file: shared_file.write(task_token)
def heartbeating_activity(self, repeat_num): for i in range(repeat_num): time.sleep(0.2) get_context().heartbeat(str(i))