Skip to content

Commit

Permalink
Merge pull request #719 from aparcar/pipecapture
Browse files Browse the repository at this point in the history
enable PipeCaptures
  • Loading branch information
KimiNewt authored Dec 4, 2024
2 parents 9baf604 + b914104 commit fac8b61
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/pyshark/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ class UnsupportedVersionException(Exception):
from pyshark.capture.file_capture import FileCapture
from pyshark.capture.remote_capture import RemoteCapture
from pyshark.capture.inmem_capture import InMemCapture
from pyshark.capture.pipe_capture import PipeCapture
15 changes: 15 additions & 0 deletions src/pyshark/capture/pipe_capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,18 @@ def close(self):
# Close pipe
os.close(self._pipe)
super(PipeCapture, self).close()

def sniff_continuously(self, packet_count=None):
"""
Captures from the set interface, returning a generator which returns packets continuously.
Can be used as follows:
for packet in capture.sniff_continuously();
print 'Woo, another packet:', packet
Note: you can also call capture.apply_on_packets(packet_callback) which should have a slight performance boost.
:param packet_count: an amount of packets to capture, then stop.
"""
# Retained for backwards compatibility and to add documentation.
return self._packets_from_tshark_sync(packet_count=packet_count)

0 comments on commit fac8b61

Please sign in to comment.