# #
###############################################################################
+import asyncio
import westferry
-s = westferry.services.WebService(debug=True)
-s.run()
+async def run():
+ # Create the web service
+ s = westferry.services.WebService(debug=True)
+
+ # Run the service
+ await s.run()
+
+asyncio.run(run())
# #
###############################################################################
-import tornado.httpserver
-import tornado.ioloop
+import asyncio
from . import application
def make_application(self, **kwargs):
return application.WebApplication(**kwargs)
- @property
- def ioloop(self):
- return tornado.ioloop.IOLoop.instance()
-
- def run(self, **kwargs):
+ async def run(self, **kwargs):
app = self.make_application(debug=self.debug, **kwargs)
- # Create a HTTP server instance
- server = tornado.httpserver.HTTPServer(app)
- server.bind(self.port)
-
- # Launch the server
- server.start()
+ # Listen on the configured port
+ app.listen(self.port, xheaders=True)
- # Launch the IOLoop
- self.ioloop.start()
+ # Wait for forever
+ await asyncio.Event().wait()