async def setUpClass(cls): cls.exc_id = gen_unique_id()[:8] name = cls.__name__.lower() argv = [ __file__, 'pulse', '-b', '127.0.0.1:0', '--concurrency', cls.concurrency, '--exc-id', cls.exc_id, '--pulse-app-name', name, '--data-store', 'pulsar://127.0.0.1:6410/1' ] cls.app_cfg = await send('arbiter', 'run', start_server, name, argv) assert cls.app_cfg.exc_id == cls.exc_id, "Bad execution id" addr = cls.app_cfg.addresses[0] cls.uri = 'http://{0}:{1}'.format(*addr) cls.ws = 'ws://{0}:{1}/message'.format(*addr) cls.http = http.HttpClient()
async def setUpClass(cls): cls.exc_id = gen_unique_id()[:8] name = cls.__name__.lower() argv = [__file__, 'pulse', '-b', '127.0.0.1:0', '--concurrency', cls.concurrency, '--exc-id', cls.exc_id, '--pulse-app-name', name, '--data-store', 'pulsar://127.0.0.1:6410/1'] cls.app_cfg = await send('arbiter', 'run', start_server, name, argv) assert cls.app_cfg.exc_id == cls.exc_id, "Bad execution id" addr = cls.app_cfg.addresses[0] cls.uri = 'http://{0}:{1}'.format(*addr) cls.ws = 'ws://{0}:{1}/message'.format(*addr) cls.http = http.HttpClient()
def _create_task(self, jobname, meta_params=None, expiry=None, queue=True, **kwargs): '''Try to queue a new :ref:`Task`. This method returns a :class:`.Future` which results in the task ``id`` created. If ``jobname`` is not a valid :attr:`.Job.name`, a ``TaskNotAvailable`` exception occurs. :param jobname: the name of a :class:`.Job` registered with the :class:`.TaskQueue` application. :param meta_params: Additional parameters to be passed to the :class:`Task` constructor (not its callable function). :param expiry: optional expiry timestamp to override the default expiry of a task. :param kwargs: optional dictionary used for the key-valued arguments in the task callable. :return: a :class:`.Future` resulting in a task once finished or Nothing ''' if self._closing: self.logger.warning('Cannot queue task, task backend closing') return if jobname in self.registry: job = self.registry[jobname] task_id = gen_unique_id() queued = time.time() if expiry is not None: expiry = get_time(expiry, queued) elif job.timeout: expiry = get_time(job.timeout, queued) meta_params = meta_params or {} if queue is not False: if queue is True: queue = job.queue or self.cfg.default_task_queue if self.cfg.task_queue_prefix: queue = '%s_%s' % (self.cfg.task_queue_prefix, queue) else: queue = None return Task(task_id, name=job.name, queue=queue, time_queued=queued, expiry=expiry, kwargs=kwargs, status=states.QUEUED, **meta_params) else: raise TaskNotAvailable(jobname)
def makeid(self): '''Can be re-implemented by your own Proxy''' return gen_unique_id()
def create_aid(): return gen_unique_id()[:8]
def makeid(self): """Can be re-implemented by your own Proxy""" return gen_unique_id()