def test_gets_class(self): """Ensure that reference_to_path can get the path of a class.""" from furious.job_utils import reference_to_path path = reference_to_path(ThrowAway) self.assertEqual('furious.tests.test_job_utils.ThrowAway', path)
def test_gets_class(self): """Ensure that reference_to_path can get the path of a class.""" from furious.job_utils import reference_to_path path = reference_to_path(ThrowAway) self.assertEqual('furious.tests.test_job_utils.ThrowAway', path)
def to_dict(self): """Return this Context as a dict suitable for json encoding.""" import copy options = copy.deepcopy(self._options) if self._insert_tasks: options['insert_tasks'] = reference_to_path(self._insert_tasks) if self._persistence_engine: options['persistence_engine'] = reference_to_path( self._persistence_engine) options.update({ '_tasks_inserted': self._tasks_inserted, '_task_ids': [async.id for async in self._tasks] })
def encode_async_options(async): """Encode Async options for JSON encoding.""" options = copy.deepcopy(async._options) options['_type'] = reference_to_path(async.__class__) # JSON don't like datetimes. eta = options.get('task_args', {}).get('eta') if eta: options['task_args']['eta'] = time.mktime(eta.timetuple()) callbacks = async._options.get('callbacks') if callbacks: options['callbacks'] = encode_callbacks(callbacks) if '_context_checker' in options: _checker = options.pop('_context_checker') options['__context_checker'] = reference_to_path(_checker) return options
def to_dict(self): """Return this Context as a dict suitable for json encoding.""" import copy options = copy.deepcopy(self._options) if self._insert_tasks: options['insert_tasks'] = reference_to_path(self._insert_tasks) if self._persistence_engine: options['persistence_engine'] = reference_to_path( self._persistence_engine) options.update({ '_tasks_inserted': self._tasks_inserted, }) callbacks = self._options.get('callbacks') if callbacks: options['callbacks'] = encode_callbacks(callbacks) return options
def to_dict(self): """Return this Context as a dict suitable for json encoding.""" import copy options = copy.deepcopy(self._options) if self._insert_tasks: options['insert_tasks'] = reference_to_path(self._insert_tasks) if self._persistence_engine: options['persistence_engine'] = reference_to_path( self._persistence_engine) options.update({ '_tasks_inserted': self._tasks_inserted, }) callbacks = self._options.get('callbacks') if callbacks: options['callbacks'] = encode_callbacks(callbacks) return options
def update_options(self, **options): """Safely update this async job's configuration options.""" _check_options(options) if 'persistence_engine' in options: options['persistence_engine'] = reference_to_path( options['persistence_engine']) if 'id' in options: self._id = options['id'] self._options.update(options)
def update_options(self, **options): """Safely update this async job's configuration options.""" _check_options(options) if 'persistence_engine' in options: options['persistence_engine'] = reference_to_path( options['persistence_engine']) if 'id' in options: self._id = options['id'] self._options.update(options)
def encode_async_options(async): """Encode Async options for JSON encoding.""" options = copy.deepcopy(async ._options) options['_type'] = reference_to_path(async .__class__) # JSON don't like datetimes. eta = options.get('task_args', {}).get('eta') if eta: options['task_args']['eta'] = time.mktime(eta.timetuple()) callbacks = async ._options.get('callbacks') if callbacks: options['callbacks'] = encode_callbacks(callbacks) if '_context_checker' in options: _checker = options.pop('_context_checker') options['__context_checker'] = reference_to_path(_checker) return options
def __init__(self, **options): self._tasks = [] self._tasks_inserted = False self._insert_success_count = 0 self._insert_failed_count = 0 self._persistence_engine = options.get('persistence_engine', None) if self._persistence_engine: options['persistence_engine'] = reference_to_path( self._persistence_engine) self._options = options if '_task_ids' not in self._options: self._options['_task_ids'] = [] self._id = self._get_id() self._result = None self._insert_tasks = options.pop('insert_tasks', _insert_tasks) if not callable(self._insert_tasks): raise TypeError('You must provide a valid insert_tasks function.')
def __init__(self, **options): self._tasks = [] self._tasks_inserted = False self._insert_success_count = 0 self._insert_failed_count = 0 self._persistence_engine = options.get('persistence_engine', None) if self._persistence_engine: options['persistence_engine'] = reference_to_path( self._persistence_engine) self._options = options if '_task_ids' not in self._options: self._options['_task_ids'] = [] self._id = self._get_id() self._result = None self._insert_tasks = options.pop('insert_tasks', _insert_tasks) if not callable(self._insert_tasks): raise TypeError('You must provide a valid insert_tasks function.')
def __init__(self, **options): self._tasks = [] self._task_ids = [] self._tasks_inserted = False self._insert_success_count = 0 self._insert_failed_count = 0 id = options.get('id') if not id: id = uuid.uuid4().hex self._id = id self._persistence_engine = options.get('persistence_engine', None) if self._persistence_engine: options['persistence_engine'] = reference_to_path( self._persistence_engine) self._options = options self._insert_tasks = options.pop('insert_tasks', _insert_tasks) if not callable(self._insert_tasks): raise TypeError('You must provide a valid insert_tasks function.')