Skip to content

Commit

Permalink
Update task: add Registry class and global instance registry
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Leclercq committed Jul 16, 2014
1 parent 038d284 commit e853d49
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions simpleflow/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import json
import abc
import collections


class Task(object):
Expand Down Expand Up @@ -49,3 +50,17 @@ def __init__(self, workflow, *args, **kwargs):
@property
def name(self):
return 'workflow-{}'.format(self.workflow.name)


class Registry(object):
def __init__(self):
self._tasks = collections.defaultdict(list)

def __getitem__(self, label):
return self._tasks[label]

def register(self, task, label=None):
self._tasks[label].append(task)


registry = Registry()

0 comments on commit e853d49

Please sign in to comment.