Skip to content

Commit

Permalink
Update docs (#7316)
Browse files Browse the repository at this point in the history
Call main() does not returns any loop. Close #7314
  • Loading branch information
serhii73 committed Jun 9, 2023
1 parent 2843883 commit 6f3e7f4
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 15 deletions.
3 changes: 1 addition & 2 deletions docs/client_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ Usage example::
html = await fetch(client)
print(html)

loop = asyncio.get_event_loop()
loop.run_until_complete(main())
asyncio.run(main())


The client session supports the context manager protocol for self closing.
Expand Down
6 changes: 2 additions & 4 deletions docs/http_request_lifecycle.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ So you are expected to reuse a session object and make many requests from it. Fo
html = await response.text()
print(html)
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
asyncio.run(main())
Can become this:
Expand All @@ -98,8 +97,7 @@ Can become this:
html = await fetch(session, 'http://python.org')
print(html)
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
asyncio.run(main())
On more complex code bases, you can even create a central registry to hold the session object from anywhere in the code, or a higher level ``Client`` class that holds a reference to it.

Expand Down
3 changes: 1 addition & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ Client example
html = await response.text()
print("Body:", html[:15], "...")
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
asyncio.run(main())
This prints:

Expand Down
8 changes: 1 addition & 7 deletions docs/web_lowlevel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,7 @@ The following code demonstrates very trivial usage example::
await asyncio.sleep(100*3600)


loop = asyncio.get_event_loop()

try:
loop.run_until_complete(main())
except KeyboardInterrupt:
pass
loop.close()
asyncio.run(main())


In the snippet we have ``handler`` which returns a regular
Expand Down

0 comments on commit 6f3e7f4

Please sign in to comment.