Carreau on main
MAINT: fix typing mypy 1.0 MAINT: fix typing mypy 1.0 (#13… (compare)
Carreau on main
Replace usage of os.devnull wit… Replace usage of os.devnull wit… (compare)
blink1073 on pre-commit-ci-update-config
blink1073 on main
[pre-commit.ci] pre-commit auto… (compare)
pre-commit-ci[bot] on pre-commit-ci-update-config
[pre-commit.ci] auto fixes from… (compare)
blink1073 on pre-commit-ci-update-config
sync deps and lint (compare)
[I 13:59:36.224 NotebookApp] KernelRestarter: restarting kernel (1/5), keep random ports
kernel b4f40812-cf7d-4f97-925b-84780f946bc9 restarted
Hello, can I embed ipython in an async program? can't seem to find any docs on it. I've tried:
import nest_asyncio
nest_asyncio.apply()
IPython.embed(using='asyncio')
with no luck 😐️
Hello! I'm seeing an issue with my IPython setup on Mac, where attempting to use await
with an async command results in the following error:
648
649 if self._local._loop is None:
--> 650 raise RuntimeError('There is no current event loop in thread %r.'
651 % threading.current_thread().name)
652
RuntimeError: There is no current event loop in thread 'MainThread'.
I've traced it to the fact that the following call always errors out:
import asyncio
asyncio.get_event_loop()
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-6-6908e23590ee> in <module>
----> 1 asyncio.get_event_loop()
/usr/local/Cellar/python@3.9/3.9.7_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/events.py in get_event_loop(self)
648
649 if self._local._loop is None:
--> 650 raise RuntimeError('There is no current event loop in thread %r.'
651 % threading.current_thread().name)
652
RuntimeError: There is no current event loop in thread 'MainThread'.
Python 3.9.7, IPython 7.30.0.
Reproducible test case:
Python 3.9.7 (default, Oct 13 2021, 06:45:31)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.30.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: async def ping():
...: pass
...:
In [2]:
In [2]: await ping()
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
/usr/local/lib/python3.9/site-packages/IPython/core/async_helpers.py in __call__(self, coro)
26 import asyncio
27
---> 28 return asyncio.get_event_loop().run_until_complete(coro)
29
30 def __str__(self):
/usr/local/Cellar/python@3.9/3.9.7_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/events.py in get_event_loop(self)
644
645 if self._local._loop is None:
--> 646 raise RuntimeError('There is no current event loop in thread %r.'
647 % threading.current_thread().name)
648
RuntimeError: There is no current event loop in thread 'MainThread'.
In [2]:
import warnings
warnings.simplefilter('once', RuntimeWarning)
def x():
warnings.warn('xx', RuntimeWarning)
x()
C:\Program Files (x86)\Python37-32\Scripts\ipython:2: RuntimeWarning: xx
x()
C:\Program Files (x86)\Python37-32\Scripts\ipython:2: RuntimeWarning: xx
I expect the warning just show once, i try the same code with python, it work as expect. what's wrong here?