Martin Richard added the comment:

The goal of the patch is to create a duplicate selector (a new epoll() 
structure with the same watched fds as the original epoll). It allows to remove 
fds watched in the child's loop without impacting the parent process.

Actually, it's true that with the current implementation of the selectors 
module (using get_map()), we can achieve the same result than with victor's 
patch without touching the selector module. I attached a patch doing that, also 
working with python 3.4.

I thought about this at_fork() mechanism a bit more and I'm not sure of what we 
want to achieve with this. In my opinion, most of the time, we will want to 
recycle the loop in the child process (close it and create a new one) because 
we will not want to have the tasks and callbacks scheduled on the loop running 
on both the parent and the child (it would probably result in double writes on 
sockets, or double reads, for instance).

With the current implementation of asyncio, I can't recycle the loop for a 
single reason: closing the loop calls _close_self_pipe() which unregisters the 
pipe of the selector (hence breaking the loop in the parent). Since the self 
pipe is an object internal to the loop, I think it's safe to close the pipes 
without unregistering them of the selector. It is at least true with epoll() 
according to the documentation quoted by neologix, but I hope that we can 
expect it to be true with other unix platforms too.

----------
Added file: http://bugs.python.org/file38164/at_fork-3.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue21998>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to