KimiNewt / pyshark

Python wrapper for tshark, allowing python packet parsing using wireshark dissectors
MIT License
2.21k stars 421 forks source link

Gets error "Error on reading from the event loop self pipe" at exit after parsing pcapng file #487

Open MortenZdk opened 3 years ago

MortenZdk commented 3 years ago

The single.pcapng file (attached in .zip) contains a single packet, and is parsed with the script:

import pyshark

cap = pyshark.FileCapture('single.pcapng')

print('# WP: Before')
print(cap[0])
print('# WP: After') 

This results in the output, with error after the print of packet:

# WP: Before ... # WP: After Error on reading from the event loop self pipe loop: \ Traceback (most recent call last): File "C:\Python39\lib\asyncio\proactor_events.py", line 777, in _loop_self_reading f = self._proactor.recv(self._ssock, 4096) File "C:\Python39\lib\asyncio\windows_events.py", line 445, in recv self._register_with_iocp(conn) File "C:\Python39\lib\asyncio\windows_events.py", line 718, in _register_with_iocp _overlapped.CreateIoCompletionPort(obj.fileno(), self._iocp, 0, 0) OSError: [WinError 87] The parameter is incorrect

So it appears that the error occurs at exit of script, and not during execution.

Versions:

single.zip

ixfd64 commented 3 years ago

Try closing the FileCapture object with cap.close() before the script finishes.

heathdbrown commented 2 years ago

I was getting the WinError 87 and the suggested .close() on the capture fixed it, thanks @ixfd64.