diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2022-12-31 21:35:12 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2022-12-31 21:35:12 +0000 |
commit | a9538199ddfd1cf0a932d3150c0f417293a6f7ca (patch) | |
tree | b305e9cb7a86415298fc9cd9db9bf0bc409982b6 /test | |
parent | b0d93435f65f6de01ad60797d43ef158a762f7f4 (diff) | |
download | rspamd-a9538199ddfd1cf0a932d3150c0f417293a6f7ca.tar.gz rspamd-a9538199ddfd1cf0a932d3150c0f417293a6f7ca.zip |
[Test] Use asyncio
Diffstat (limited to 'test')
-rwxr-xr-x | test/functional/util/dummy_http.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/test/functional/util/dummy_http.py b/test/functional/util/dummy_http.py index 5052f51b6..a88b64801 100755 --- a/test/functional/util/dummy_http.py +++ b/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 @@ -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") @@ -128,13 +129,16 @@ if __name__ == "__main__": 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())
\ No newline at end of file |