pyshark
pyshark copied to clipboard
Run the packet parsing event loop in a different thread.
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 https://github.com/ipython/ipython/issues/11030 , I've tried to come up with a little code to make pyshark run in Jupyter Notebooks.
Any progress on this? Or workaround? I am new to python multiprocessing / asyncio
. Could we somehow make this patch working?
+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.
This patch is so important for my workflow that I'm using md11235's fork of pyshark now. Thanks md11235!
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.
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.
Any progress on the PR? If this works now, we should close this!