diff --git a/src/pyshark/capture/file_capture.py b/src/pyshark/capture/file_capture.py index 3946b821..ad768e6f 100644 --- a/src/pyshark/capture/file_capture.py +++ b/src/pyshark/capture/file_capture.py @@ -86,3 +86,14 @@ def __repr__(self): return '<%s %s>' % (self.__class__.__name__, self.input_filename) else: return '<%s %s (%d packets)>' % (self.__class__.__name__, self.input_filename, len(self._packets)) + + def close(self): + super(FileCapture,self).close() + self.eventloop.close() + + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_value, exc_traceback ): + self.close() +