Skip to content

Commit 3bc68cf

Browse files
miss-islingtonasvetlov
authored andcommitted
bpo-26133: Dont unsubscribe signals in UNIX even loop on interpreter shutdown (GH-4956) (#4962)
(cherry picked from commit 4a02543)
1 parent fdb148f commit 3bc68cf

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

‎Lib/asyncio/unix_events.py‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,14 @@ def _socketpair(self):
6161

6262
def close(self):
6363
super().close()
64-
for sig in list(self._signal_handlers):
65-
self.remove_signal_handler(sig)
64+
if not sys.is_finalizing():
65+
for sig in list(self._signal_handlers):
66+
self.remove_signal_handler(sig)
67+
else:
68+
warinigs.warn(f"Closing the loop {self!r} on interpreter shutdown "
69+
f"stage, signal unsubsription is disabled",
70+
ResourceWarning,
71+
source=self)
6672

6773
def _process_self_data(self, data):
6874
for signum in data:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Don't unsubscribe signals in asyncio UNIX event loop on interpreter shutdown.

0 commit comments

Comments
 (0)