コード例 #1
0
ファイル: thread.py プロジェクト: solebox/WorQ
 def __init__(self, broker, workers=1, thread_factory=Thread):
     self.broker = broker
     self.workers = workers
     self.thread_factory = thread_factory
     self.threads = []
     self.stop_event = Event()
     ts = TaskSpace(__name__)
     ts.task(lambda: None, 'noop')
     broker.expose(ts, replace=True)
コード例 #2
0
ファイル: thread.py プロジェクト: cnsoft/WorQ
 def __init__(self, broker, workers=1, thread_factory=Thread):
     self.broker = broker
     self.workers = workers
     self.thread_factory = thread_factory
     self.threads = []
     self.stop_event = Event()
     ts = TaskSpace(__name__)
     ts.task(lambda:None, 'noop')
     broker.expose(ts, replace=True)
コード例 #3
0
ファイル: core.py プロジェクト: llazzaro/WorQ
    def expose(self, obj, replace=False):
        """Expose a TaskSpace or task callable.

        :param obj: A TaskSpace or task callable.
        :param replace: Replace existing task if True. Otherwise (by default),
            raise ValueError if this would replace an existing task.
        """
        if isinstance(obj, TaskSpace):
            space = obj
        else:
            space = TaskSpace()
            space.task(obj)
        for name, func in space.tasks.items():
            if name in self.tasks and not replace:
                raise ValueError('task %r conflicts with existing task' % name)
            self.tasks[name] = func
コード例 #4
0
ファイル: core.py プロジェクト: solebox/WorQ
    def expose(self, obj, replace=False):
        """Expose a TaskSpace or task callable.

        :param obj: A TaskSpace or task callable.
        :param replace: Replace existing task if True. Otherwise (by default),
            raise ValueError if this would replace an existing task.
        """
        if isinstance(obj, TaskSpace):
            space = obj
        else:
            space = TaskSpace()
            space.task(obj)
        for name, func in space.tasks.items():
            if name in self.tasks and not replace:
                raise ValueError('task %r conflicts with existing task' % name)
            self.tasks[name] = func