def test_validate_workflow_handler_message(): message = WorkflowSchedulingMessage(task='setup', workflow_invocation_id=42) message.validate() message = WorkflowSchedulingMessage(task='setup') error = None try: message.validate() except AssertionError as e: error = e assert error is not None
def __init__(self, app): self.app = app self.__handlers_configured = False self.workflow_schedulers = {} self.active_workflow_schedulers = {} # Passive workflow schedulers won't need to be monitored I guess. self.request_monitor = None self.handlers = {} self.handler_assignment_methods_configured = False self.handler_assignment_methods = None self.handler_max_grab = None self.default_handler_id = None self.__plugin_classes = self.__plugins_dict() self.__init_schedulers() if self._is_workflow_handler(): log.debug("Starting workflow schedulers") self.__start_schedulers() if self.active_workflow_schedulers: self.__start_request_monitor() # When assinging handlers to workflows being queued - use job_conf # if not explicit workflow scheduling handlers have be specified or # else use those explicit workflow scheduling handlers (on self). if self.__handlers_configured: self.__handlers_config = self else: self.__handlers_config = app.job_config if self._is_workflow_handler(): if self.__handlers_config.use_messaging: WorkflowSchedulingMessage().bind_default_handler( self, '_handle_message') self.app.application_stack.register_message_handler( self._handle_message, name=WorkflowSchedulingMessage.target) else: # Process should not schedule workflows but should check for any unassigned to handlers self.__startup_recovery()
def _message_callback(self, workflow_invocation): return WorkflowSchedulingMessage(task='setup', workflow_invocation_id=workflow_invocation.id)