

def __init__(self):
    if is_port_listening(TEST_PORT):
        for i in range(2):
            logging.warn('Existing daemon found. Asking it to exit')
            try:
                conn = httplib.HTTPConnection('localhost', TEST_PORT, True)
                conn.request('GET', '/exit')
            except:
                break
            res = conn.getresponse()
            if (res.status != 200):
                break
            else:
                time.sleep(0.2)
    if is_port_listening(TEST_PORT):
        raise Exception('Daemon running')
    self.daemon_settings_file = tempfile.NamedTemporaryFile()
    args = ['./quickopend', 'run', '--settings', self.daemon_settings_file.name, '--port', str(TEST_PORT)]
    args.append('--test')
    self.proc = subprocess.Popen(args)
    ok = False
    for i in range(10):
        try:
            conn = httplib.HTTPConnection('localhost', TEST_PORT, True)
            conn.request('GET', '/ping')
        except:
            time.sleep(0.1)
            continue
        res = self.getresponse()
        if (res.status != 200):
            ok = False
            break
        if (json.loads(res.read()) != 'pong'):
            ok = False
            break
        ok = True
        break
    if (not ok):
        raise Exception('Daemon did not come up')
    self._conn = None
    self._db_proxy = None

dataset/ETHPy150Open natduca/quickopen/src/temporary_daemon.py TemporaryDaemon.__init__/VarMisuse@228/307 `conn`->`self`