Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: do_one_iteration is a coroutine #830

Merged
merged 1 commit into from
Jan 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion ipykernel/eventloops.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,10 @@ def process_stream_events(stream, *a, **kw):
app.mainloop()

else:
import asyncio
import nest_asyncio
nest_asyncio.apply()

doi = kernel.do_one_iteration
# Tk uses milliseconds
poll_interval = int(1000 * kernel._poll_interval)
Expand All @@ -264,7 +268,11 @@ def __init__(self, app, func):
self.func = func

def on_timer(self):
self.func()
loop = asyncio.get_event_loop()
try:
loop.run_until_complete(self.func())
except Exception:
kernel.log.exception("Error in message handler")
self.app.after(poll_interval, self.on_timer)

def start(self):
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def run(self):
'tornado>=4.2,<7.0',
'matplotlib-inline>=0.1.0,<0.2.0',
'appnope;platform_system=="Darwin"',
'nest_asyncio',
],
extras_require={
"test": [
Expand Down