def register(): routing_key = current_task.request.delivery_info['routing_key'] probe = probes[routing_key] probe_name = type(probe).plugin_name probe_category = type(probe).plugin_category probe_regexp = type(probe).plugin_mimetype_regexp register_probe(probe_name, probe_category, probe_regexp)
def test_register_probe(self, m_async_call): module.register_probe("name", "displayname", "category", "mimetype_regexp") m_async_call.assert_called_with( module.brain_app, 'brain.scan_tasks', 'register_probe', args=['name', 'displayname', 'category', 'mimetype_regexp'])
def test_register_probe(self, m_async_call): module.register_probe("name", "displayname", "category", "mimetype_regexp") m_async_call.assert_called_with(module.brain_app, 'brain.scan_tasks', 'register_probe', args=['name', 'displayname', 'category', 'mimetype_regexp'])
def register(): routing_key = current_task.request.delivery_info['routing_key'] probe = probes[routing_key] probe_name = type(probe).plugin_name probe_display_name = type(probe).plugin_display_name probe_category = type(probe).plugin_category probe_regexp = type(probe).plugin_mimetype_regexp log.debug("queue %s probe %s category %s probe_regexp %s", probe_name, probe_display_name, probe_category, probe_regexp) register_probe(probe_name, probe_display_name, probe_category, probe_regexp)
def register(): routing_key = current_task.request.delivery_info['routing_key'] probe = probes[routing_key] probe_name = type(probe).plugin_name probe_display_name = type(probe).plugin_display_name probe_category = type(probe).plugin_category probe_regexp = type(probe).plugin_mimetype_regexp log.debug("queue %s probe %s category %s probe_regexp %s", probe_name, probe_display_name, probe_category, probe_regexp) register_probe(probe_name, probe_display_name, probe_category, probe_regexp)
queues.append(kombu.Queue(probe_name, routing_key=probe_name)) log.info('Configure Queues') # update configuration probe_app.conf.update( CELERY_QUEUES=tuple(queues), ) for p in probes: # register probe on Brain log.info('Register probe %s' % p.plugin_name) delay = 1 while True: try: task = register_probe(p.plugin_name, p.plugin_display_name, p.plugin_category, p.plugin_mimetype_regexp) task.get(timeout=10) break except (TimeoutError, IrmaTaskError): log.error("Registering on brain failed retry in %s seconds...", delay) time.sleep(delay) delay = min([2*delay, RETRY_MAX_DELAY]) pass # instantiation of probes and queue creation probes = dict((probe.plugin_name, probe()) for probe in probes) ##############################################################################
queue_arguments=probe_queues_options)) log.info('Configure Queues') # update configuration probe_app.conf.update( CELERY_QUEUES=tuple(queues), ) for p in probes: # register probe on Brain log.info('Register probe %s' % p.plugin_name) delay = 1 while True: try: task = register_probe(p.plugin_name, p.plugin_display_name, p.plugin_category, p.plugin_mimetype_regexp) task.get(timeout=10) break except (TimeoutError, IrmaTaskError): log.error("Registering on brain failed retry in %s seconds...", delay) time.sleep(delay) delay = min([2*delay, RETRY_MAX_DELAY]) pass # instantiation of probes and queue creation probes = dict((probe.plugin_name, probe()) for probe in probes) ##############################################################################
# update configuration probe_app.conf.update( CELERY_QUEUES=tuple(queues), ) for p in probes: # register probe on Brain probe_name = p.plugin_name probe_category = p.plugin_category mimetype_regexp = p.plugin_mimetype_regexp log.info('Register probe %s' % probe_name) try_nb = 1 while True: try: try_nb += 1 task = register_probe(probe_name, probe_category, mimetype_regexp) task.get(timeout=10) break except TimeoutError: log.info("Registering on brain try %s", format(try_nb)) pass # instanciation of probes and queue creation probes = dict((probe.plugin_name, probe()) for probe in probes) ############################################################################## # declare celery tasks ############################################################################## def handle_output_files(results, dstpath):