Skip to content

Commit

Permalink
Merge pull request #670 from matan1008/bugfix/ensure-close-async
Browse files Browse the repository at this point in the history
capture: Fix close_async in case the stderr task is still running
  • Loading branch information
KimiNewt authored Jul 20, 2024
2 parents 5bef368 + 4a729cf commit c89fc6e
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 inspect
import os
import threading
Expand Down Expand Up @@ -402,7 +403,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 c89fc6e

Please sign in to comment.