def start_http_server(context):
httpretty.disable()
context.http_port = get_free_tcp_port()
context.server = TornadoServer(context.http_port)
context.server.start()
ready = False
timeout = 2
started_at = time.time()
while not ready:
httpretty.disable()
time.sleep(.1)
try:
requests.get('http://localhost:{0}/'.format(context.http_port))
ready = True
except:
if time.time() - started_at >= timeout:
break
httpretty.enable()
评论列表
文章目录