Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

After apply() and asyncio.run(), Jupyter kernel cannot execute any code #87

Closed
Chaoses-Ib opened this issue Jan 7, 2024 · 7 comments
Closed

Comments

@Chaoses-Ib
Copy link

Before I call nest_asyncio.apply(), the notebook works fine. However, after I call apply() and asyncio.run(), the notebook cannot execute any cells and will block forever.

I've tested this on Python 3.9 and Python 3.12, the official Jupyter Notebook and VS Code's Jupyter Notebook extension, all have this problem. But just a few days ago there was no problem. I'm not sure what happened.

Example

# %%
import asyncio

# %%
await asyncio.sleep(1)
print(123)

# %%
print(456)

# %%
import nest_asyncio

nest_asyncio.apply()

# %%
await asyncio.sleep(1)
print(123)

# %%
asyncio.run(asyncio.sleep(1))
print(123)

# %%
print(456)

image

Packages

Package            Version
------------------ -------
aiohttp            3.9.1
aiosignal          1.3.1
asttokens          2.4.1
attrs              23.2.0
colorama           0.4.6
comm               0.2.1
debugpy            1.6.7
decorator          5.1.1
exceptiongroup     1.2.0
executing          2.0.1
frozenlist         1.4.1
idna               3.6
importlib-metadata 7.0.1
ipykernel          6.28.0
ipython            8.19.0
ipywidgets         8.1.1
jupyter_client     8.6.0
jupyter_core       5.5.0
jupyterlab-widgets 3.0.9
matplotlib-inline  0.1.6
multidict          6.0.4
nest-asyncio       1.5.8
networkx           3.2.1
packaging          23.2
parso              0.8.3
pickleshare        0.7.5
pillow             10.2.0
pip                23.3.1
platformdirs       4.1.0
prompt-toolkit     3.0.42
psutil             5.9.0
pure-eval          0.2.2
Pygments           2.17.2
python-dateutil    2.8.2
pywin32            305.1
pyzmq              25.1.0
setuptools         68.2.2
six                1.16.0
stack-data         0.6.2
tornado            6.3.3
traitlets          5.14.1
typing_extensions  4.9.0
wcwidth            0.2.12
wheel              0.41.2
widgetsnbextension 4.0.9
yarl               1.9.4
zipp               3.17.0
@erdewit
Copy link
Owner

erdewit commented Jan 7, 2024

The above example code runs fine for me on Jupyter notebook, Jupyter lab en VSCode. This is with Python 3.12.1 and the latest relevant packages.

jupyter-events==0.9.0
jupyter-lsp==2.2.0
jupyter_client==8.6.0
jupyter_core==5.5.0
jupyter_server==2.10.0
jupyter_server_terminals==0.4.4
jupyterlab==4.0.10
jupyterlab-pygments==0.2.2
jupyterlab_server==2.25.1

@erdewit erdewit closed this as completed Jan 7, 2024
@Chaoses-Ib
Copy link
Author

I created an env with Python 3.12.1 and the packages you listed. The problem can still be reproduced on Jupyter Notebook, Jupyter Lab and VS Code.

Python 3.12.1 | packaged by conda-forge | (main, Dec 23 2023, 07:53:56) [MSC v.1937 64 bit (AMD64)] on win32
Package                   Version
------------------------- ---------------
anyio                     4.2.0
argon2-cffi               23.1.0
argon2-cffi-bindings      21.2.0
arrow                     1.3.0
asttokens                 2.4.1
async-lru                 2.0.4
attrs                     23.2.0
Babel                     2.14.0
beautifulsoup4            4.12.2
bleach                    6.1.0
certifi                   2023.11.17
cffi                      1.16.0
charset-normalizer        3.3.2
colorama                  0.4.6
comm                      0.2.1
debugpy                   1.8.0
decorator                 5.1.1
defusedxml                0.7.1
executing                 2.0.1
fastjsonschema            2.19.1
fqdn                      1.5.1
idna                      3.6
ipykernel                 6.28.0
ipython                   8.19.0
isoduration               20.11.0
jedi                      0.19.1
Jinja2                    3.1.2
json5                     0.9.14
jsonpointer               2.4
jsonschema                4.20.0
jsonschema-specifications 2023.12.1
jupyter_client            8.6.0
jupyter_core              5.5.0
jupyter-events            0.9.0
jupyter-lsp               2.2.0
jupyter_server            2.10.0
jupyter_server_terminals  0.4.4
jupyterlab                4.0.10
jupyterlab-pygments       0.2.2
jupyterlab_server         2.25.1
MarkupSafe                2.1.3
matplotlib-inline         0.1.6
mistune                   3.0.2
nbclient                  0.9.0
nbconvert                 7.14.0
nbformat                  5.9.2
nest-asyncio              1.5.8
notebook_shim             0.2.3
overrides                 7.4.0
packaging                 23.2
pandocfilters             1.5.0
parso                     0.8.3
pip                       23.3.2
platformdirs              4.1.0
prometheus-client         0.19.0
prompt-toolkit            3.0.43
psutil                    5.9.7
pure-eval                 0.2.2
pycparser                 2.21
Pygments                  2.17.2
python-dateutil           2.8.2
python-json-logger        2.0.7
pywin32                   306
pywinpty                  2.0.12
PyYAML                    6.0.1
pyzmq                     25.1.2
referencing               0.32.1
requests                  2.31.0
rfc3339-validator         0.1.4
rfc3986-validator         0.1.1
rpds-py                   0.16.2
Send2Trash                1.8.2
setuptools                69.0.3
six                       1.16.0
sniffio                   1.3.0
soupsieve                 2.5
stack-data                0.6.3
terminado                 0.18.0
tinycss2                  1.2.1
tornado                   6.4
traitlets                 5.14.1
types-python-dateutil     2.8.19.20240106
uri-template              1.3.0
urllib3                   2.1.0
wcwidth                   0.2.13
webcolors                 1.13
webencodings              0.5.1
websocket-client          1.7.0
wheel                     0.42.0

image

image

image

@erdewit
Copy link
Owner

erdewit commented Jan 7, 2024

What's your OS?

@Chaoses-Ib
Copy link
Author

Windows 11 23H2 (22631.2861). Just tried, in my WSL2 there is no such problem. Maybe I should just stop using Windows...

@Chaoses-Ib
Copy link
Author

I found someone who had the exact same problem as me, although it was about three years ago: winpython/winpython#950

@erdewit
Copy link
Owner

erdewit commented Jan 8, 2024

It will be a long while before I can test this on Windows.

@erdewit erdewit reopened this Jan 15, 2024
@Chaoses-Ib
Copy link
Author

👍Upgraded to v1.5.9 and now it's working fine.

Chaoses-Ib added a commit to Chaoses-Ib/ComfyScript that referenced this issue Jan 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants