A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2013-August/128045.html below:

[Python-Dev] PEP 446: issue with sockets

[Python-Dev] PEP 446: issue with socketsVictor Stinner victor.stinner at gmail.com
Wed Aug 21 01:30:23 CEST 2013
Hi,

I have a new question for my PEP 446 (inheritance of file descriptors).

os.get/set_inheritable(handle) has strange behaviour on Windows, and
so I would like to add new os.get/set_handle_inheritable() functions
to avoid it. The problem is that a socket would require a different
function depending on the OS: os.get/set_handle_inheritable() on
Windows, os.get/set_inheritable() on UNIX. Should I add a portable
helper to the socket module (socket.get/set_inheritable)? 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.set_inheritable(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.set_interiable() function which accepts both
types.

The issue is that os.get_inheritable() does the same guess and it has
a strange behaviour. Calling os.get_inheritable() 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
get_inheritable() 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.get_handle_inheritable() and os.set_handle_inheritable().

Victor
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4