Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/pyshark/capture/capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,14 @@ def _verify_capture_parameters(self):

def _setup_eventloop(self):
"""Sets up a new eventloop as the current one according to the OS."""
if sys.version_info >= (3, 14):
try:
self.eventloop = asyncio.get_event_loop()
except RuntimeError:
self.eventloop = asyncio.new_event_loop()
asyncio.set_event_loop(self.eventloop)
return

if os.name == "nt":
current_eventloop = asyncio.get_event_loop_policy().get_event_loop()
if isinstance(current_eventloop, asyncio.ProactorEventLoop):
Expand Down
11 changes: 7 additions & 4 deletions tests/test_cap_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

import pytest

import pyshark
from pyshark.packet.packet_summary import PacketSummary
from tests.conftest import example_pcap_path


def test_packet_callback_called_for_each_packet(lazy_simple_capture):
Expand Down Expand Up @@ -60,17 +62,18 @@ def test_getting_packet_summary(simple_summary_capture):
assert simple_summary_capture[0]._fields


def _iterate_capture_object(cap_obj, q):
def _iterate_capture_object(example_pcap_path, q):
cap_obj = pyshark.FileCapture(example_pcap_path, debug=True, only_summaries=True)
cap_obj.display_filter = "frame.len == 1"
for _ in cap_obj:
pass
q.put(True)


def test_iterate_empty_psml_capture(simple_summary_capture):
simple_summary_capture.display_filter = "frame.len == 1"
def test_iterate_empty_psml_capture(example_pcap_path):
q = Queue()
p = Process(target=_iterate_capture_object,
args=(simple_summary_capture, q))
args=(example_pcap_path, q))
p.start()
p.join(2)
try:
Expand Down