def fake_poll(self): polled_activity_data = json.loads(b64decode(self.poll_data)) activity_task = BaseActivityTask.from_poll( self.domain, self.task_list, polled_activity_data, ) return Response( task_token=activity_task.task_token, activity_task=activity_task, raw_response=polled_activity_data, )
def poll(self, task_list=None, identity=None): """Polls for an activity task to process from current actor's instance defined ``task_list`` if no activity task was polled, raises a PollTimeout exception. :param task_list: task list the Actor should watch for tasks on :type task_list: string :param identity: Identity of the worker making the request, which is recorded in the ActivityTaskStarted event in the workflow history. This enables diagnostic tracing when problems arise. The form of this identity is user defined. :type identity: string :raises: PollTimeout :returns: task token, polled activity task :rtype: (str, ActivityTask) """ logging_context.reset() task_list = task_list or self.task_list identity = identity or self._identity try: task = self.connection.poll_for_activity_task( self.domain.name, task_list, identity=format.identity(identity), ) except boto.exception.SWFResponseError as e: message = self.get_error_message(e) if e.error_code == "UnknownResourceFault": raise DoesNotExistError( "Unable to poll activity task", message, ) raise ResponseError(message) if not task.get("taskToken"): raise PollTimeout("Activity Worker poll timed out") logging_context.set("workflow_id", task["workflowExecution"]["workflowId"]) logging_context.set("task_type", "activity") logging_context.set("event_id", task["startedEventId"]) logging_context.set("activity_id", task["activityId"]) activity_task = ActivityTask.from_poll(self.domain, self.task_list, task,) return Response( task_token=activity_task.task_token, activity_task=activity_task, raw_response=task, )
def poll(self, task_list=None, identity=None): """Polls for an activity task to process from current actor's instance defined ``task_list`` if no activity task was polled, raises a PollTimeout exception. :param task_list: task list the Actor should watch for tasks on :type task_list: string :param identity: Identity of the worker making the request, which is recorded in the ActivityTaskStarted event in the workflow history. This enables diagnostic tracing when problems arise. The form of this identity is user defined. :type identity: string :raises: PollTimeout :returns: polled activity task :type: swf.models.ActivityTask """ task_list = task_list or self.task_list identity = identity or self._identity try: polled_activity_data = self.connection.poll_for_activity_task( self.domain.name, task_list, identity=identity ) except boto.exception.SWFResponseError as e: if e.error_code == 'UnknownResourceFault': raise DoesNotExistError( "Unable to poll activity task.\n", e.body['message'] ) raise ResponseError(e.body['message']) if not 'taskToken' in polled_activity_data: raise PollTimeout("Activity Worker poll timed out") activity_task = ActivityTask.from_poll( self.domain, self.task_list, polled_activity_data ) task_token = activity_task.task_token return task_token, activity_task
def poll(self, task_list=None, identity=None): """Polls for an activity task to process from current actor's instance defined ``task_list`` if no activity task was polled, raises a PollTimeout exception. :param task_list: task list the Actor should watch for tasks on :type task_list: string :param identity: Identity of the worker making the request, which is recorded in the ActivityTaskStarted event in the workflow history. This enables diagnostic tracing when problems arise. The form of this identity is user defined. :type identity: string :raises: PollTimeout :returns: task token, polled activity task :rtype: (str, ActivityTask) """ task_list = task_list or self.task_list identity = identity or self._identity try: polled_activity_data = self.connection.poll_for_activity_task( self.domain.name, task_list, identity=identity) except boto.exception.SWFResponseError as e: message = self.get_error_message(e) if e.error_code == 'UnknownResourceFault': raise DoesNotExistError( "Unable to poll activity task", message, ) raise ResponseError(message) if 'taskToken' not in polled_activity_data: raise PollTimeout("Activity Worker poll timed out") activity_task = ActivityTask.from_poll(self.domain, self.task_list, polled_activity_data) task_token = activity_task.task_token return task_token, activity_task
def poll(self, task_list=None, identity=None): """Polls for an activity task to process from current actor's instance defined ``task_list`` if no activity task was polled, raises a PollTimeout exception. :param task_list: task list the Actor should watch for tasks on :type task_list: string :param identity: Identity of the worker making the request, which is recorded in the ActivityTaskStarted event in the workflow history. This enables diagnostic tracing when problems arise. The form of this identity is user defined. :type identity: string :raises: PollTimeout :returns: task token, polled activity task :rtype: (str, ActivityTask) """ logging_context.reset() task_list = task_list or self.task_list identity = identity or self._identity try: task = self.connection.poll_for_activity_task( self.domain.name, task_list, identity=format.identity(identity), ) except boto.exception.SWFResponseError as e: message = self.get_error_message(e) if e.error_code == 'UnknownResourceFault': raise DoesNotExistError( "Unable to poll activity task", message, ) raise ResponseError(message) if 'taskToken' not in task: raise PollTimeout("Activity Worker poll timed out") logging_context.set("workflow_id", task["workflowExecution"]["workflowId"]) logging_context.set("task_type", "activity") logging_context.set("event_id", task["startedEventId"]) logging_context.set("activity_id", task["activityId"]) activity_task = ActivityTask.from_poll( self.domain, self.task_list, task, ) return Response( task_token=activity_task.task_token, activity_task=activity_task, raw_response=task, )