avoid deprecated IOLoop.current() call without running loop
This commit is contained in:
parent
e461599184
commit
020c2f3fe0
10
README.rst
10
README.rst
|
@ -20,7 +20,8 @@ Here is a simple "Hello, world" example web app for Tornado:
|
|||
|
||||
.. code-block:: python
|
||||
|
||||
import tornado.ioloop
|
||||
import asyncio
|
||||
|
||||
import tornado.web
|
||||
|
||||
class MainHandler(tornado.web.RequestHandler):
|
||||
|
@ -32,10 +33,13 @@ Here is a simple "Hello, world" example web app for Tornado:
|
|||
(r"/", MainHandler),
|
||||
])
|
||||
|
||||
if __name__ == "__main__":
|
||||
async def main():
|
||||
app = make_app()
|
||||
app.listen(8888)
|
||||
tornado.ioloop.IOLoop.current().start()
|
||||
await asyncio.Event().wait()
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
|
||||
This example does not use any of Tornado's asynchronous features; for
|
||||
that see this `simple chat room
|
||||
|
|
|
@ -8,10 +8,16 @@ configuring a WSGI container to find your application, you write a
|
|||
|
||||
.. testcode::
|
||||
|
||||
def main():
|
||||
import asyncio
|
||||
|
||||
async def amain():
|
||||
app = make_app()
|
||||
app.listen(8888)
|
||||
IOLoop.current().start()
|
||||
await asyncio.Event().wait()
|
||||
|
||||
|
||||
def main():
|
||||
asyncio.run(amain())
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -16,7 +16,8 @@ A minimal "hello world" example looks something like this:
|
|||
|
||||
.. testcode::
|
||||
|
||||
import tornado.ioloop
|
||||
import asyncio
|
||||
|
||||
import tornado.web
|
||||
|
||||
class MainHandler(tornado.web.RequestHandler):
|
||||
|
@ -28,10 +29,13 @@ A minimal "hello world" example looks something like this:
|
|||
(r"/", MainHandler),
|
||||
])
|
||||
|
||||
if __name__ == "__main__":
|
||||
async def main():
|
||||
app = make_app()
|
||||
app.listen(8888)
|
||||
tornado.ioloop.IOLoop.current().start()
|
||||
await asyncio.Event().wait()
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
|
||||
.. testoutput::
|
||||
:hide:
|
||||
|
|
|
@ -31,7 +31,8 @@ Hello, world
|
|||
|
||||
Here is a simple "Hello, world" example web app for Tornado::
|
||||
|
||||
import tornado.ioloop
|
||||
import asyncio
|
||||
|
||||
import tornado.web
|
||||
|
||||
class MainHandler(tornado.web.RequestHandler):
|
||||
|
@ -43,10 +44,13 @@ Here is a simple "Hello, world" example web app for Tornado::
|
|||
(r"/", MainHandler),
|
||||
])
|
||||
|
||||
if __name__ == "__main__":
|
||||
async def main():
|
||||
app = make_app()
|
||||
app.listen(8888)
|
||||
tornado.ioloop.IOLoop.current().start()
|
||||
await asyncio.Event().wait()
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
|
||||
This example does not use any of Tornado's asynchronous features; for
|
||||
that see this `simple chat room
|
||||
|
|
Loading…
Reference in New Issue