本文整理汇总了Python中SpiffWorkflow.specs.TaskSpec.TaskSpec类的典型用法代码示例。如果您正苦于以下问题:Python TaskSpec类的具体用法?Python TaskSpec怎么用?Python TaskSpec使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TaskSpec类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self,
parent,
name,
times = None,
times_attribute = None,
**kwargs):
"""
Constructor.
@type parent: L{SpiffWorkflow.specs.WorkflowSpec}
@param parent: A reference to the parent (usually a workflow).
@type name: string
@param name: A name for the task.
@type times: int or None
@param times: The number of tasks to create.
@type times_attribute: str or None
@param times_attribute: The name of an attribute that specifies
the number of outgoing tasks.
@type kwargs: dict
@param kwargs: See L{SpiffWorkflow.specs.TaskSpec}.
"""
if not times_attribute and not times:
raise ValueError('require times or times_attribute argument')
TaskSpec.__init__(self, parent, name, **kwargs)
self.times_attribute = times_attribute
self.times = times
self.thread_starter = ThreadStart(parent, **kwargs)
self.outputs.append(self.thread_starter)
self.thread_starter._connect_notify(self)
示例2: __init__
def __init__(self,
parent,
name,
split_task=None,
threshold=None,
cancel=False,
**kwargs):
"""
Constructor.
@type parent: L{SpiffWorkflow.specs.WorkflowSpec}
@param parent: A reference to the parent (usually a workflow).
@type name: string
@param name: A name for the task.
@type split_task: str or None
@param split_task: The name of the task spec that was previously
used to split the branch. If this is None,
the most recent branch split is merged.
@type threshold: int or L{SpiffWorkflow.operators.Attrib}
@param threshold: Specifies how many incoming branches need to
complete before the task triggers. When the limit
is reached, the task fires but still expects all
other branches to complete.
You may also pass an attribute, in which case
the value is resolved at runtime.
@type cancel: bool
@param cancel: When True, any remaining incoming branches are
cancelled as soon as the discriminator is activated.
@type kwargs: dict
@param kwargs: See L{SpiffWorkflow.specs.TaskSpec}.
"""
TaskSpec.__init__(self, parent, name, **kwargs)
self.split_task = split_task
self.threshold = threshold
self.cancel_remaining = cancel
示例3: __init__
def __init__(self,
parent,
name,
file,
in_assign = None,
out_assign = None,
**kwargs):
"""
Constructor.
:type parent: TaskSpec
:param parent: A reference to the parent task spec.
:type name: str
:param name: The name of the task spec.
:type file: str
:param file: The name of a file containing a workflow.
:type in_assign: list(str)
:param in_assign: The names of attributes to carry over.
:type out_assign: list(str)
:param out_assign: The names of attributes to carry back.
:type kwargs: dict
:param kwargs: See L{SpiffWorkflow.specs.TaskSpec}.
"""
assert parent is not None
assert name is not None
assert file is not None
TaskSpec.__init__(self, parent, name, **kwargs)
self.file = None
self.in_assign = in_assign is not None and in_assign or []
self.out_assign = out_assign is not None and out_assign or []
if file is not None:
dirname = os.path.dirname(parent.file)
self.file = os.path.join(dirname, file)
示例4: test
def test(self):
"""
Checks whether all required attributes are set. Throws an exception
if an error was detected.
"""
TaskSpec.test(self)
if len(self.outputs) > 0:
raise WorkflowException(self, "Cancel with an output.")
示例5: __init__
def __init__(self, parent, **kwargs):
"""
Constructor. The name of this task is *always* 'Start'.
:type parent: TaskSpec
:param parent: A reference to the parent task spec.
:type kwargs: dict
:param kwargs: See L{SpiffWorkflow.specs.TaskSpec}.
"""
TaskSpec.__init__(self, parent, 'Start', **kwargs)
示例6: __init__
def __init__(self, parent, **kwargs):
"""
Constructor. The name of this task is *always* 'ThreadStart'.
@type parent: TaskSpec
@param parent: A reference to the parent task spec.
@type kwargs: dict
@param kwargs: See L{SpiffWorkflow.specs.TaskSpec}.
"""
TaskSpec.__init__(self, parent, 'ThreadStart', **kwargs)
self.internal = True
示例7: _on_complete_hook
def _on_complete_hook(self, my_task):
context = my_task.workflow.get_task_spec_from_name(self.context)
triggered = []
for task in my_task.workflow.task_tree:
if task.thread_id != my_task.thread_id:
continue
if task.task_spec == context:
task.trigger(self.choice)
triggered.append(task)
for task in triggered:
context._predict(task)
TaskSpec._on_complete_hook(self, my_task)
示例8: __init__
def __init__(self, parent, name, call=None, call_args=None, call_queue=None, call_server_id=None,
call_result_key=None, merge_results=True, **kwargs):
"""Constructor.
The args/kwargs arguments support Attrib classes in the parameters for
delayed evaluation of inputs until run-time. Example usage:
task = Celery(wfspec, 'MyTask', 'celery.call',
call_args=['hello', 'world', Attrib('number')],
any_param=Attrib('result'))
For serialization, the celery task_id is stored in internal_data,
but the celery async call is only storred as an attr of the task (since
it is not always serializable). When deserialized, the async_call attr
is reset in the _try_fire call.
:type parent: TaskSpec
:param parent: A reference to the parent task spec.
:type name: str
:param name: The name of the task spec.
:type call: str
:param call: The name of the celery task that needs to be called.
:type call_args: list
:param call_args: args to pass to celery task.
:type call_result_key: str
:param call_result_key: The key to use to store the results of the call in
task.data. If None, then dicts are expanded into
data and values are stored in 'result'.
:param merge_results: merge the results in instead of overwriting existing
fields.
:type kwargs: dict
:param kwargs: kwargs to pass to celery task.
"""
if not have_celery:
raise Exception("Unable to import python-celery imports.")
assert parent is not None
assert name is not None
if call is None:
call = name
TaskSpec.__init__(self, parent, name, **kwargs)
self.description = kwargs.pop('description', '')
self.call = call
self.args = call_args
self.call_queue = call_queue
self.call_server_id = call_server_id
self.merge_results = merge_results
skip = 'data', 'defines', 'pre_assign', 'post_assign', 'lock'
self.kwargs = dict(i for i in kwargs.iteritems() if i[0] not in skip)
self.call_result_key = call_result_key
LOG.debug("Celery task '%s' created to call '%s'", name, call)
示例9: _on_complete_hook
def _on_complete_hook(self, my_task):
"""
A hook into _on_complete() that does the task specific work.
:type my_task: Task
:param my_task: A task in which this method is executed.
:rtype: bool
:returns: True on success, False otherwise.
"""
for i in range(self.times + self.queued):
for task_name in self.context:
task = my_task.workflow.get_task_spec_from_name(task_name)
task._on_trigger(my_task)
self.queued = 0
TaskSpec._on_complete_hook(self, my_task)
示例10: __init__
def __init__(self, parent, name, success=False, **kwargs):
"""
Constructor.
:type parent: TaskSpec
:param parent: A reference to the parent task spec.
:type name: str
:param name: The name of the task spec.
:type success: bool
:param success: Whether to cancel successfully or unsuccessfully.
:type kwargs: dict
:param kwargs: See L{SpiffWorkflow.specs.TaskSpec}.
"""
TaskSpec.__init__(self, parent, name, **kwargs)
self.cancel_successfully = success
示例11: __init__
def __init__(self, parent, name, times = None, **kwargs):
"""
Constructor.
@type parent: TaskSpec
@param parent: A reference to the parent task spec.
@type name: str
@param name: The name of the task spec.
@type times: int
@param times: The number of tasks to create.
@type kwargs: dict
@param kwargs: See L{SpiffWorkflow.specs.TaskSpec}.
"""
TaskSpec.__init__(self, parent, name, **kwargs)
self.times = times
示例12: __init__
def __init__(self, parent, name, mutex, **kwargs):
"""
Constructor.
:type parent: TaskSpec
:param parent: A reference to the parent task spec.
:type name: str
:param name: The name of the task spec.
:type mutex: str
:param mutex: The name of the mutex that should be acquired.
:type kwargs: dict
:param kwargs: See L{SpiffWorkflow.specs.TaskSpec}.
"""
assert mutex is not None
TaskSpec.__init__(self, parent, name, **kwargs)
self.mutex = mutex
示例13: __init__
def __init__(self, parent, name, args=None, **kwargs):
"""
Constructor.
:type parent: TaskSpec
:param parent: A reference to the parent task spec.
:type name: str
:param name: The name of the task spec.
:type args: list
:param args: args to pass to process (first arg is the command).
:type kwargs: dict
:param kwargs: kwargs to pass-through to TaskSpec initializer.
"""
assert parent is not None
assert name is not None
TaskSpec.__init__(self, parent, name, **kwargs)
self.args = args
示例14: _on_complete_hook
def _on_complete_hook(self, my_task):
context = my_task.workflow.get_task_spec_from_name(self.context)
for task in my_task.workflow.task_tree:
if task.thread_id != my_task.thread_id:
continue
if task.task_spec == context:
task.trigger(self.choice)
return TaskSpec._on_complete_hook(self, my_task)
示例15: __init__
def __init__(self, parent, name, call, call_args=None, result_key=None,
merge_results=False, **kwargs):
"""Constructor.
The args/kwargs arguments support Attrib classes in the parameters for
delayed evaluation of inputs until run-time. Example usage:
task = Celery(wfspec, 'MyTask', 'celery.call',
call_args=['hello', 'world', Attrib('number')],
any_param=Attrib('result'))
For serialization, the celery task_id is stored in internal_attributes,
but the celery async call is only storred as an attr of the task (since
it is not always serializable). When deserialized, the async_call attr
is reset in the try_fire call.
@type parent: TaskSpec
@param parent: A reference to the parent task spec.
@type name: str
@param name: The name of the task spec.
@type call: str
@param call: The name of the celery task that needs to be called.
@type call_args: list
@param call_args: args to pass to celery task.
@type result_key: str
@param result_key: The key to use to store the results of the call in
task.attributes. If None, then dicts are expanded into
attributes and values are stored in 'result'.
@param merge_results: merge the results in instead of overwriting existing
fields.
@type kwargs: dict
@param kwargs: kwargs to pass to celery task.
"""
assert parent is not None
assert name is not None
assert call is not None
TaskSpec.__init__(self, parent, name, **kwargs)
self.description = kwargs.pop('description', '')
self.call = call
self.args = call_args
self.merge_results = merge_results
self.kwargs = {key: kwargs[key] for key in kwargs if key not in \
['properties', 'defines', 'pre_assign', 'post_assign', 'lock']}
self.result_key = result_key
LOG.debug("Celery task '%s' created to call '%s'" % (name, call))