Skip to content

Commit

Permalink
Temp fix for ipykernel >= 5, handle Future returned by do_one_iterati…
Browse files Browse the repository at this point in the history
…on().

In ipykernel >= 5, do_one_iteration() has been changed into a coroutine and
returns a Future. This Future  needs to be processed appropriately, if not the
kernel will die with an error "execution aborted" (see #26) due to the coroutine
not having completed execution. To fix this, have ipython_kernel_iteration()
complete execution of the coroutine before continuing.

This is just a temporary fix, will need checks so the code works on
ipykernel < 5.
  • Loading branch information
zerotypic authored and marc-etienne committed Dec 21, 2020
1 parent 36f96f1 commit 7ff0aac
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ipyida/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import os
import idaapi

import asyncio

# The IPython kernel will override sys.std{out,err}. We keep a copy to let the
# existing embeded IDA console continue working, and also let IPython output to
# it.
Expand Down Expand Up @@ -101,7 +103,8 @@ def start(self):
self.connection_file = app.connection_file

def ipython_kernel_iteration():
app.kernel.do_one_iteration()
f = app.kernel.do_one_iteration()
asyncio.get_event_loop().run_until_complete(f)
return int(1000 * app.kernel._poll_interval)
self._timer = idaapi.register_timer(int(1000 * app.kernel._poll_interval), ipython_kernel_iteration)

Expand Down

0 comments on commit 7ff0aac

Please sign in to comment.