Пример #1
0
def _create_celery():
    from celery import Celery
    from phovea_server.plugin import list as list_plugins
    from phovea_server.config import view as config_view

    # set configured registry
    plugins = list_plugins('processing-task')
    cc = config_view('phovea_processing_queue')
    print(cc.get('celery.name'), cc.get('celery.broker'),
          cc.get('celery.backend'))

    def _map(p):
        # print 'add processing tasks: ' + p.module
        _log.info('add processing task: %s', p.module)
        return p.module

    task_modules = list(map(_map, plugins))

    app = Celery(cc.get('celery.name'),
                 broker=cc.get('celery.broker'),
                 backend=cc.get('celery.backend'),
                 include=task_modules)

    # Optional configuration, see the application user guide.
    app.conf.update(CELERY_TASK_RESULT_EXPIRES=cc.getint('celery.expires'))
    return app
Пример #2
0
 def __init__(self):
     from phovea_server.plugin import lookup
     from phovea_server.config import view as config_view
     # call lookup to enforce registry initialization which triggers configuration initialization
     lookup('test')
     cc = config_view('phovea_processing_queue.celery')
     self._db = redis.Redis(host=cc.host, port=cc.port, db=cc.db)
     self._channel_name = 'phovea_processing_channel'
Пример #3
0
from phovea_server import ns
from phovea_server.config import view as config_view
import memcache
import logging
import gevent
import gevent.lock

__author__ = 'Samuel Gratzl'
app = ns.Namespace(__name__)
conf = config_view('phovea_clue')

mc = memcache.Client(conf.get('memcached'), debug=0)
mc_prefix = 'clue_'

_log = logging.getLogger(__name__)


class Screenshotter(object):
  def __init__(self):
    self._lock = gevent.lock.BoundedSemaphore(1)
    self._timeout = None
    self._driver = None
    pass

  def _timed_out(self):
    try:
      _log.info('quiting driver')
      self._driver.quit()
      _log.info('quitted driver')
    finally:
      self._driver = None