Aiohttp: [JupyterLab] TypeError: object _SessionRequestContextManager can't be used in 'await' expression

Created on 17 Sep 2019  路  1Comment  路  Source: aio-libs/aiohttp

Long story short

resp = await aiohttp.request('GET', 'http://flupy.org/data/flags/cn/cn.gif')
D:\Continuum\anaconda3\lib\site-packages\ipykernel_launcher.py:4: RuntimeWarning: coroutine 'ClientSession._request' was never awaited
  after removing the cwd from sys.path.
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x0000000008F0B048>

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-30-35d97f3baca0> in async-def-wrapper()

TypeError: object _SessionRequestContextManager can't be used in 'await' expression

Expected behaviour

Get the URL

Actual behaviour

TypeError

Steps to reproduce

Everytime

Your environment

Anaconda 3, Python 3.7.3 aiohttp 3.6.0

invalid wontfix

Most helpful comment

It deliberately can not.
Please use async with aiohttp.request('GET', 'http://flupy.org/data/flags/cn/cn.gif') as resp: ... to explicitly control the response lifecycle.

>All comments

It deliberately can not.
Please use async with aiohttp.request('GET', 'http://flupy.org/data/flags/cn/cn.gif') as resp: ... to explicitly control the response lifecycle.

Was this page helpful?
0 / 5 - 0 ratings