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

Windows: no running event loop, when using pyshark.FileCapture() #674

Open
DanielSchwartz1 opened this issue Dec 8, 2023 · 3 comments
Open
Labels

Comments

@DanielSchwartz1
Copy link

DanielSchwartz1 commented Dec 8, 2023

I've written a python code which is calling the FileCapture function like:
capture = pyshark.FileCapture(file_path)
to extract certain information from the capture.

On Unix systems all is working properly.
But on Windows clients (e.g. Windows 11), I receive the error:
"no running event loop"

I've also checked the other issues ongoing and I saw similar threads.
I've tried to close the capture with:
capture.close()

But it does not work anyway.

Expected behavior
I've expected to have extracted all information without the error "no running event loop"

Versions (please complete the following information):

  • OS: Windows 11
  • python version: 3.7
  • tshark version: 4.0.10

Example pcap / packet
Does not work with any pcap file.

Do you have by chance a workaround for it?

Thank you!

@rpkh
Copy link

rpkh commented Dec 26, 2023

I'm running on Windows 11 and it seems to be working fine for me?

  • OS: Windows 11 22H2
  • python version: 3.11.5
  • pyshark version: 0.6
  • tshark version: 4.0.10
import pyshark

capfile = "D:\\test.pcapng"
capture = pyshark.FileCapture(capfile)
capture.load_packets()
print(len(capture))

@DanielSchwartz1
Copy link
Author

I fixed my problem - it is related to the python version.
At the end it was a matter to apply the workaround to be (again) compatible with Python Version 3.7.
It is described here: #642

@naivecoder-irl
Copy link

naivecoder-irl commented Jun 27, 2024

I solved the issue by explicitly setting the event loop and passing it into FileCapture in Python 3.11.6

import asyncio
loop = asyncio.ProactorEventLoop()
asyncio.set_event_loop(loop)
pcap_file ='D:\\x.x.x.x_cap1.cap'
display_filter = 'tcp.analysis.retransmission or tcp.analysis.duplicate_ack'
cap = pyshark.FileCapture(pcap_file,eventloop=loop,display_filter=display_filter)
print(cap[0])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants