Skip to content

Run the packet parsing event loop in a different thread.#291

Open
md11235 wants to merge 1 commit into
KimiNewt:masterfrom
md11235:master
Open

Run the packet parsing event loop in a different thread.#291
md11235 wants to merge 1 commit into
KimiNewt:masterfrom
md11235:master

Conversation

@md11235

@md11235 md11235 commented Aug 29, 2018

Copy link
Copy Markdown

So that pyshark can be used in Jupyter Notebooks.

The version by KimiNewt works like a charm! I've use this library heavily win python scripts run in the command line. But when this version is run in a Jupyter Notebook, it will complain:

RuntimeError: Cannot run the event loop while another loop is running

After digging around the web, based on a code snippet from @fortuna at ipython/ipython#11030 , I've tried to come up with a little code to make pyshark run in Jupyter Notebooks.

So that pyshark can be used in Jupyter Notebooks.
@letalvoj

Copy link
Copy Markdown

Any progress on this? Or workaround? I am new to python multiprocessing / asyncio. Could we somehow make this patch working?

@jkbecker

Copy link
Copy Markdown

+1 on being really interested in a solution. Not being able to run pyshark from within a Jupyter Notebook is really annoying...
I'm not in a position to say whether this pull request will have any negative side effects, but I'd appreciate a lot of someone could look into integrating it if it's all good.

@jjoonathan

Copy link
Copy Markdown

This patch is so important for my workflow that I'm using md11235's fork of pyshark now. Thanks md11235!

@salijona

salijona commented Aug 26, 2019

Copy link
Copy Markdown

I am using a workaround for now with nest_asyncio package.
import nest_asyncio
nest_asyncio.apply()

Although I would be interested to see if there is a solution that can be integrated within pyshark.

@KimiNewt

KimiNewt commented Aug 26, 2019

Copy link
Copy Markdown
Owner

Jupyter can run it now, assuming you exclusively use the async methods. I'll try to work on adding the missing ones but you can use ones like cap.packets_from_tshark inside jupyter.

nest_asyncio is also an interesting solution, I'll look into that.

@XChikuX

XChikuX commented Jan 31, 2023

Copy link
Copy Markdown

Any progress on the PR?
If this works now, we should close this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants