KimiNewt / pyshark

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

raise RuntimeError('This event loop is already running') #630

Open saifjarboui opened 1 year ago

saifjarboui commented 1 year ago

Describe the bug When running filecapture of a bit large pcap file (around 100MB) ; I get

Exception ignored in: <function Capture.__del__ at 0x0000021793F5F040>
Traceback (most recent call last):
  File "C:\Python39\lib\site-packages\pyshark\capture\capture.py", line 406, in __del__
    self.close()
  File "C:\Python39\lib\site-packages\pyshark\capture\capture.py", line 394, in close
    self.eventloop.run_until_complete(self.close_async())
  File "C:\Python39\lib\asyncio\base_events.py", line 618, in run_until_complete
    self._check_running()
  File "C:\Python39\lib\asyncio\base_events.py", line 578, in _check_running
    raise RuntimeError('This event loop is already running')
RuntimeError: This event loop is already running
C:\Python39\lib\site-packages\pyshark\packet\layers\xml_layer.py:26: RuntimeWarning:
coroutine 'Capture.close_async' was never awaited

and in other times I get :

Exception ignored in: <function Capture.__del__ at 0x0000021793F5F040>
Traceback (most recent call last):
  File "C:\Python39\lib\site-packages\pyshark\capture\capture.py", line 406, in __del__
    self.close()
  File "C:\Python39\lib\site-packages\pyshark\capture\capture.py", line 394, in close
    self.eventloop.run_until_complete(self.close_async())
  File "C:\Python39\lib\asyncio\base_events.py", line 618, in run_until_complete
    self._check_running()
  File "C:\Python39\lib\asyncio\base_events.py", line 578, in _check_running
    raise RuntimeError('This event loop is already running')
RuntimeError: This event loop is already running

To Reproduce Run filecapture in the context that Tshark called many times before closed

Expected behavior A clear and concise description of what you expected to happen.

Versions (please complete the following information):

Kastalia commented 1 year ago

Solved #366