

@contextmanager
def run_kuyruk(queue='kuyruk', terminate=True):
    assert not_running()
    args = [sys.executable, '-u', '-m', 'kuyruk.__main__', '--app', 'tests.tasks.kuyruk', 'worker', '--queue', queue]
    environ = os.environ.copy()
    environ['COVERAGE_PROCESS_START'] = '.coveragerc'
    popen = What(*popen, preexec_fn=os.setsid, env=environ)
    popen.timeout = TIMEOUT
    try:
        (yield popen)
        if terminate:
            popen.terminate()
            popen.expect('End run worker')
        popen.expect_exit()
    finally:
        try:
            popen.kill()
            popen.wait()
        except OSError as e:
            if (e.errno != errno.ESRCH):
                raise
        logger.debug('Worker return code: %s', popen.returncode)
        try:
            wait_while((lambda : get_pids('kuyruk:')))
        except KeyboardInterrupt:
            print(popen.get_output())
            raise Exception

dataset/ETHPy150Open cenk/kuyruk/tests/integration/util.py run_kuyruk/VarMisuse@70/117 `args`->`popen`