Skip to content

Commit

Permalink
if __name__ == '__main__', fix #3775 (#3788)
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelcolvin authored and asvetlov committed May 21, 2019
1 parent e54e7cc commit 506c244
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES/3775.doc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use ``if __name__ == '__main__':`` in server examples.
3 changes: 2 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ An example using a simple server:
web.get('/echo', wshandle),
web.get('/{name}', handle)])
web.run_app(app)
if __name__ == '__main__':
web.run_app(app)
Documentation
Expand Down
8 changes: 5 additions & 3 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ Client example::
html = await fetch(session, 'http://python.org')
print(html)

loop = asyncio.get_event_loop()
loop.run_until_complete(main())
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(main())

Server example::

Expand All @@ -92,7 +93,8 @@ Server example::
app.add_routes([web.get('/', handle),
web.get('/{name}', handle)])

web.run_app(app)
if __name__ == '__main__':
web.run_app(app)


For more information please visit :ref:`aiohttp-client` and
Expand Down

0 comments on commit 506c244

Please sign in to comment.