summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2025-06-22 15:35:07 +0200
committerHelmut Grohne <helmut@subdivi.de>2025-06-22 15:35:07 +0200
commitfc3d65d0b5c0273dcdd18e422fa4766e1fbd859e (patch)
tree8794846d023f91bc81584ca7babbc332e379a5b9
parenta4a6280ff83aa4a1e44a5e2f9c9fa375e5bf60c0 (diff)
downloadpython-linuxnamespaces-fc3d65d0b5c0273dcdd18e422fa4766e1fbd859e.tar.gz
async_run_in_fork: explicitly give up on the event loop
The forked process still shares file descriptors with its parent running asyncio code. Having two processes deal with the same epoll fd or similar would be really bad. Hence release the event loop in the child to prevent accidental use.
-rw-r--r--linuxnamespaces/__init__.py1
1 files changed, 1 insertions, 0 deletions
diff --git a/linuxnamespaces/__init__.py b/linuxnamespaces/__init__.py
index 5b163df..21afd4a 100644
--- a/linuxnamespaces/__init__.py
+++ b/linuxnamespaces/__init__.py
@@ -106,6 +106,7 @@ class async_run_in_fork:
self.efd.read()
self.efd.close()
self.efd = None
+ asyncio.set_event_loop(None)
function()
except:
os._exit(1)