jupyter-server-proxy: NoneType can't be used in 'await' expression - May be harmless

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

About this issue

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

Most upvoted comments

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

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.

Okay, nevermind- this works! I realized my dask-yarn was starting in remote mode instead of local mode and I think that was the issue.