question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NoneType can't be used in 'await' expression - May be harmless

See original GitHub issue

Ran into the following traceback when using dask-labextension with jupyter-server-proxy. This occurred with Tornado 6, but went away with Tornado 5. Am using JupyterLab 0.35.4, dask-labextension 0.3.1, Bokeh 1.0.4, and jupyter-server-proxy 1.0.0.

LabApp - ERROR - Uncaught exception GET /proxy/9100/status (10.110.73.60)
HTTPServerRequest(protocol='http', host='10.31.241.45:9999', method='GET', uri='/proxy/9100/status', version='HTTP/1.1', remote_ip='10.110.73.60')
Traceback (most recent call last):
  File "/home/nfs/jkirkham/miniconda/envs/rapidsdev37/lib/python3.7/site-packages/tornado/web.py", line 1699, in _execute
    result = await result
  File "/home/nfs/jkirkham/miniconda/envs/rapidsdev37/lib/python3.7/site-packages/jupyter_server_proxy/websocket.py", line 87, in get
    return await self.http_get(*args, **kwargs)
  File "/home/nfs/jkirkham/miniconda/envs/rapidsdev37/lib/python3.7/site-packages/jupyter_server_proxy/handlers.py", line 247, in http_get
    return await self.proxy(port, proxy_path)
TypeError: object NoneType can't be used in 'await' expression
LabApp - ERROR - Uncaught exception GET /proxy/9100/status (10.110.73.60)
HTTPServerRequest(protocol='http', host='10.31.241.45:9999', method='GET', uri='/proxy/9100/status', version='HTTP/1.1', remote_ip='10.110.73.60')
Traceback (most recent call last):
  File "/home/nfs/jkirkham/miniconda/envs/rapidsdev37/lib/python3.7/site-packages/tornado/web.py", line 1699, in _execute
    result = await result
  File "/home/nfs/jkirkham/miniconda/envs/rapidsdev37/lib/python3.7/site-packages/jupyter_server_proxy/websocket.py", line 87, in get
    return await self.http_get(*args, **kwargs)
  File "/home/nfs/jkirkham/miniconda/envs/rapidsdev37/lib/python3.7/site-packages/jupyter_server_proxy/handlers.py", line 247, in http_get
    return await self.proxy(port, proxy_path)
TypeError: object NoneType can't be used in 'await' expression

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:15 (9 by maintainers)

github_iconTop GitHub Comments

4reactions
maresbcommented, May 22, 2020

Running code-server with tornado==6.0.4, jupyter-server-proxy==1.5.0, jupyterlab==2.1.1, and jupyterlab_server==1.1.1 I periodically encounter the following, which refers to this line of handlers.py:

[E 19:33:44.192 LabApp] Uncaught exception GET /vscode/update (172.18.0.1)
    HTTPServerRequest(protocol='http', host='127.0.0.1:8888', method='GET', uri='/vscode/update', version='HTTP/1.1', remote_ip='172.18.0.1')
    Traceback (most recent call last):
      File "/opt/conda/lib/python3.7/site-packages/tornado/web.py", line 1703, in _execute
        result = await result
      File "/opt/conda/lib/python3.7/site-packages/jupyter_server_proxy/websocket.py", line 97, in get
        return await self.http_get(*args, **kwargs)
      File "/opt/conda/lib/python3.7/site-packages/jupyter_server_proxy/handlers.py", line 534, in http_get
        return await self.proxy(self.port, path)
    TypeError: object NoneType can't be used in 'await' expression
1reaction
maresbcommented, Feb 3, 2021

I considered bundling a fix in https://github.com/jupyterhub/jupyter-server-proxy/pull/209 but it was way too complicated already.

I haven’t understood #239 yet but, ignoring testing issues, and if I remember correctly, to solve this issue one simply needs to add checks to all await statements that one isn’t awaiting None. My solution was to write a helper function, something along the lines of

async def await_if_not_none(awaitable):
    if awaitable is not None:
        return await awaitable

and then replace most await calls with this. (Disclaimer: I’m writing from memory and that’s not tested.)

However, I’m not an asyncio expert (yet), and I don’t know if there’s a more elegant way.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: object NoneType can't be used in 'await' expression
The solution is simple, remove the await in front of the do_something() since it's not async. Share.
Read more >
TypeError: Object nontype can't be used in 'await' expression
Functions you're going to use with await have to be "awaitable", which means they can't return None when you call them. Are you...
Read more >
coroutine 'clientsession._request' was never awaited - You.com
First urllib is a blocking library, you can't create a task from it, neither can ... TypeError: object NoneType can't be used in...
Read more >
Python Asyncio for Beginners - Medium
TypeError : object NoneType can't be used in 'await' expression. Say what? This error seems very strange at first.
Read more >
Changelog — Python 3.11.1 documentation
gh-98086: Make sure patch.dict() can be applied on async functions. ... of potential harmless “malloc can't allocate region” messages spewed ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found