@contextmanager
def _start_worker_thread(app, concurrency=1, pool=u'solo', loglevel=WORKER_LOGLEVEL, logfile=None, WorkController=TestWorkController, **kwargs):
 setup_app_for_worker(app, loglevel, logfile)
 assert (u'celery.ping' in app.tasks)
 with app.connection() as conn:
  conn.default_channel.queue_declare
 worker = WorkController(app=app, concurrency=concurrency, hostname=anon_nodename(), pool=pool, loglevel=loglevel, logfile=logfile, ready_callback=None, without_heartbeat=True, without_mingle=True, without_gossip=True, **kwargs)
 t = threading.Thread(target=worker.start)
 t.start()
 worker.ensure_started()
 _set_task_join_will_block(False)
 (yield worker)
 from celery.worker import state
 state.should_terminate = 0
 t.join(10)
 state.should_terminate = None

@ contextmanager def _start_worker_thread ( app , concurrency = 1 , pool = u'solo' , loglevel = WORKER_LOGLEVEL , logfile = None , WorkController = TestWorkController , ** kwargs ) : setup_app_for_worker ( app , loglevel , logfile ) assert ( u'celery.ping' in app . tasks ) with app . connection ( ) as conn : conn . default_channel . queue_declare worker = WorkController ( app = app , concurrency = concurrency , hostname = anon_nodename ( ) , pool = pool , loglevel = loglevel , logfile = logfile , ready_callback = None , without_heartbeat = True , without_mingle = True , without_gossip = True , ** kwargs ) t = threading . Thread ( target = worker . start ) t . start ( ) worker . ensure_started ( ) _set_task_join_will_block ( False ) ( yield worker ) from celery . worker import state state . should_terminate = 0 t . join ( 10 ) state . should_terminate = None
start celery worker in a thread .