File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -14,4 +14,31 @@ Example:
1414
1515.. literalinclude :: ../code_examples/aiohttp_async.py
1616
17+ IPython
18+ -------
19+
20+ .. Attention ::
21+
22+ On some Python environments, like :emphasis: `Jupyter ` or :emphasis: `Spyder `,
23+ which are using :emphasis: `IPython `,
24+ an asyncio event loop is already created for you by the environment.
25+
26+ In this case, running the above code might generate the following error::
27+
28+ RuntimeError: asyncio.run() cannot be called from a running event loop
29+
30+ If that happens, depending on the environment,
31+ you should replace :code: `asyncio.run(main()) ` by either:
32+
33+ .. code-block :: python
34+
35+ await main()
36+
37+ OR:
38+
39+ .. code-block :: python
40+
41+ loop = asyncio.get_running_loop()
42+ loop.create_task(main())
43+
1744 .. _asyncio : https://docs.python.org/3/library/asyncio.html
You can’t perform that action at this time.
0 commit comments