[Python-Dev] PEP 446: issue with sockets (original) (raw)
Guido van Rossum guido at python.org
Wed Aug 21 01:57:46 CEST 2013
- Previous message: [Python-Dev] PEP 446: issue with sockets
- Next message: [Python-Dev] PEP 446: issue with sockets
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Agreed that guessing whether something's a handle or not is terrible. If this is truly only for sockets then maybe it should live in the socket module?
Also, are you sure the things returned by socket.fleno() are really Windows handles? I thought they were some other artificial namespace used just by sockets.
On Tue, Aug 20, 2013 at 4:30 PM, Victor Stinner <victor.stinner at gmail.com>wrote:
Hi,
I have a new question for my PEP 446 (inheritance of file descriptors). os.get/setinheritable(handle) has strange behaviour on Windows, and so I would like to add new os.get/sethandleinheritable() functions to avoid it. The problem is that a socket would require a different function depending on the OS: os.get/sethandleinheritable() on Windows, os.get/setinheritable() on UNIX. Should I add a portable helper to the socket module (socket.get/setinheritable)? Or add 2 methods to the socket class? Now the details. I have an issue with sockets and the PEP 446. On Windows, my implementation of the os.setinheritable(fd: int, inheritable: bool) function tries to guess if fd is a file descriptor or a handle. The reason is that the fileno() method of a socket returns a file descriptor on UNIX, whereas it returns a handle on Windows. It is convinient to have a os.setinteriable() function which accepts both types. The issue is that os.getinheritable() does the same guess and it has a strange behaviour. Calling os.getinheritable() with integers in the range(20) has a border effect: open(filename) creates a file descriptor 10, whereas it creates a file descriptor 3 if getinheritable() was not called (why 10 and not 3?). To avoid the border effect, it's better to not guess if the parameter is a file descriptor or a Windows handle, and a new two new functions: os.gethandleinheritable() and os.sethandleinheritable(). Victor
Python-Dev mailing list Python-Dev at python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/guido%40python.org
-- --Guido van Rossum (python.org/~guido) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20130820/f2fa3cf9/attachment.html>
- Previous message: [Python-Dev] PEP 446: issue with sockets
- Next message: [Python-Dev] PEP 446: issue with sockets
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]