Skip to content

Commit

Permalink
[Test] Use asyncio
Browse files Browse the repository at this point in the history
  • Loading branch information
vstakhov committed Dec 31, 2022
1 parent b0d9343 commit a953819
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions test/functional/util/dummy_http.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python3

import asyncio
import tornado.ioloop
import tornado.web
import tornado.httpserver
Expand Down Expand Up @@ -107,7 +108,7 @@ def make_app():
(r"(/[^/]+)", MainHandler),
])

if __name__ == "__main__":
async def main():
parser = argparse.ArgumentParser()
parser.add_argument("--bind", "-b", default="localhost", help="bind address")
parser.add_argument("--port", "-p", type=int, default=18080, help="bind port")
Expand All @@ -128,13 +129,16 @@ def make_app():
else:
server = tornado.httpserver.HTTPServer(app)

# Start the server
server.bind(args.port, args.bind)
server.start(1)

# Write the PID to the specified PID file, if provided
if args.pidfile:
with open(args.pidfile, "w") as f:
f.write(str(os.getpid()))

tornado.ioloop.IOLoop.current().start()
# Start the server
server.bind(args.port, args.bind)
server.start(1)

await asyncio.Event().wait()

if __name__ == "__main__":
asyncio.run(main())

0 comments on commit a953819

Please sign in to comment.