From 33feb442e4684302080fddcafd1a8adda4e0c71a Mon Sep 17 00:00:00 2001 From: Nocturn9x Date: Fri, 12 May 2023 09:14:00 +0200 Subject: [PATCH] Fixed wrong warning about pending I/O in Task destructor --- aiosched/io.py | 1 - aiosched/task.py | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/aiosched/io.py b/aiosched/io.py index d48c79e..92323eb 100644 --- a/aiosched/io.py +++ b/aiosched/io.py @@ -99,7 +99,6 @@ class AsyncStream: await io_release(self.stream) self.stream.close() self.stream = None - await aiosched.checkpoint() async def fileno(self): """ diff --git a/aiosched/task.py b/aiosched/task.py index b669686..ee65683 100644 --- a/aiosched/task.py +++ b/aiosched/task.py @@ -142,5 +142,5 @@ class Task: if not self.done(): warnings.warn(f"task '{self.name}' was destroyed, but it has not completed yet") - if self.last_io: - warnings.warn(f"task '{self.name}' was destroyed, but it has pending I/O") + if self.last_io and self.last_io[1].fileno() != -1: + warnings.warn(f"task '{self.name}' was destroyed, but it has pending I/O: forgot to close a resource?")