OSX PyShark: RuntimeWarning: coroutine 'wait_f

2019-07-14 21:50发布

问题:

I was wondering if anyone around here might know what causes this issue. I keep getting this error on OSX High Sierra, while running a python script which uses the pyshark library.

I am running

  • Tshark 2.6.2
  • Python 3.7.0
  • PyShark 0.4.1

The error:

/usr/local/lib/python3.7/site-packages/pyshark-0.4.1-py3.7.egg/pyshark/capture/capture.py:230: RuntimeWarning: coroutine 'wait_for' was never awaited
  self.eventloop.run_until_complete(self._cleanup_subprocess(tshark_process))
/usr/local/lib/python3.7/site-packages/pyshark-0.4.1-py3.7.egg/pyshark/capture/capture.py:230: RuntimeWarning: coroutine 'Process.wait' was never awaited
  self.eventloop.run_until_complete(self._cleanup_subprocess(tshark_process))

My code:

#!/usr/bin/env python3

import pyshark

def capture(iface, tout):
    cap = pyshark.LiveCapture(interface=iface);
    cap.set_debug()
    cap.sniff(timeout=10)

    for packet in cap.sniff_continuously(packet_count=5):
        print('Just arrived:', packet)


capture('en7', 50)

Executing the script using sudo does not work. And I am able to run TShark without the sudo command so that should not be an issue as well I suppose. I also started XCode to check if I needed to submit any agreement or something, which wasn't the case.