-
Notifications
You must be signed in to change notification settings - Fork 446
Open
Labels
Description
Describe the bug
cannot read pcapng file, receiving an error: AttributeError: type object '_asyncio.Task' has no attribute 'all_tasks'
File ~\Miniconda3\envs\ngnddos\lib\site-packages\pyshark\capture\file_capture.py:38, in FileCapture.__init__(self, input_file, keep_packets, display_filter, only_summaries, decryption_key, encryption_type, decode_as, disable_protocol, tshark_path, override_prefs, use_json, use_ek, output_file, include_raw, eventloop, custom_parameters, debug)
10 def __init__(self, input_file=None, keep_packets=True, display_filter=None, only_summaries=False,
11 decryption_key=None, encryption_type="wpa-pwk", decode_as=None,
12 disable_protocol=None, tshark_path=None, override_prefs=None,
13 use_json=False, use_ek=False,
14 output_file=None, include_raw=False, eventloop=None, custom_parameters=None,
15 debug=False):
16 """Creates a packet capture object by reading from file.
17
18 :param keep_packets: Whether to keep packets after reading them via next(). Used to conserve memory when reading
(...)
36 or else a list of parameters in the format ["--foo", "bar", "--baz", "foo"].
37 """
---> 38 super(FileCapture, self).__init__(display_filter=display_filter, only_summaries=only_summaries,
39 decryption_key=decryption_key, encryption_type=encryption_type,
40 decode_as=decode_as, disable_protocol=disable_protocol,
41 tshark_path=tshark_path, override_prefs=override_prefs,
42 use_json=use_json, use_ek=use_ek, output_file=output_file,
43 include_raw=include_raw, eventloop=eventloop,
44 custom_parameters=custom_parameters, debug=debug)
45 self.input_filepath = pathlib.Path(input_file)
46 if not self.input_filepath.exists():
File ~\Miniconda3\envs\ngnddos\lib\site-packages\pyshark\capture\capture.py:88, in Capture.__init__(self, display_filter, only_summaries, eventloop, decryption_key, encryption_type, output_file, decode_as, disable_protocol, tshark_path, override_prefs, capture_filter, use_json, include_raw, use_ek, custom_parameters, debug)
86 self.eventloop = eventloop
87 if self.eventloop is None:
---> 88 self._setup_eventloop()
89 if encryption_type and encryption_type.lower() in self.SUPPORTED_ENCRYPTION_STANDARDS:
90 self.encryption = (decryption_key, encryption_type.lower())
File ~\Miniconda3\envs\ngnddos\lib\site-packages\pyshark\capture\capture.py:176, in Capture._setup_eventloop(self)
172 self.eventloop = current_eventloop
173 else:
174 # On Python before 3.8, Proactor is not the default eventloop type, so we have to create a new one.
175 # If there was an existing eventloop this can create issues, since we effectively disable it here.
--> 176 if asyncio.Task.all_tasks():
177 warnings.warn("The running eventloop has tasks but pyshark must set a new eventloop to continue. "
178 "Existing tasks may not run.")
179 self.eventloop = asyncio.ProactorEventLoop()
AttributeError: type object '_asyncio.Task' has no attribute 'all_tasks'
To Reproduce
import pyshark
capture = pyshark.FileCapture('data/data.pcap')
Expected behavior
capture holds packets
Versions (please complete the following information):
- OS: Windows 10
- pyshark version: 0.5.3
- tshark version: 3.6.6
Example pcap / packet
If applicable, add an example pcap file as an attachment, or post the packet as a hex string or a JSON/XML (export packet dissection in wireshark/tshark).
Reactions are currently unavailable