Skip to content

Commit

Permalink
capture: Fix close_async in case the stderr task is still running
Browse files Browse the repository at this point in the history
  • Loading branch information
matan1008 committed Nov 2, 2023
1 parent e7da566 commit 7142c5b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/pyshark/capture/capture.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import asyncio
import contextlib
import os
import threading
import subprocess
Expand Down Expand Up @@ -398,7 +399,10 @@ async def close_async(self):
self._running_processes.clear()

# Wait for all stderr handling to finish
await asyncio.gather(*self._stderr_handling_tasks)
for task in self._stderr_handling_tasks:
task.cancel()
with contextlib.suppress(asyncio.CancelledError):
await task

def __del__(self):
if self._running_processes:
Expand Down

0 comments on commit 7142c5b

Please sign in to comment.