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

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

md11235
Copy link

@md11235 md11235 commented Aug 29, 2018

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

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

@jkbecker
Copy link

+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

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

@salijona
Copy link

salijona commented Aug 26, 2019

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
Copy link
Owner

KimiNewt commented Aug 26, 2019

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
Copy link

XChikuX commented Jan 31, 2023

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.

None yet

7 participants