[Python-Dev] PEP 3145 (With Contents)
techtonik at gmail.com
Thu Dec 20 04:46:02 CET 2012
On Thu, Dec 20, 2012 at 3:47 AM, Glyph <glyph at twistedmatrix.com> wrote:
> On Dec 19, 2012, at 2:14 PM, anatoly techtonik <techtonik at gmail.com>
> On Sun, Dec 9, 2012 at 7:14 AM, Glyph <glyph at twistedmatrix.com> wrote:
>> On Dec 7, 2012, at 5:10 PM, anatoly techtonik <techtonik at gmail.com>
>> What about reading from other file descriptors? subprocess.Popen allows
>>> arbitrary file descriptors to be used. Is there any provision here for
>>> reading and writing non-blocking from or to those?
>> On Windows it is WriteFile/ReadFile and PeekNamedPipe. On Linux it is
>> select. Of course a test is needed, but why it should not just work?
>> This is exactly why the provision needs to be made explicitly.
>> On Windows it is WriteFile and ReadFile and PeekNamedPipe - unless the
>> handle is a socket in which case it needs to be WSARecv. Or maybe it's
>> some other weird thing - like, maybe a mailslot - and you need to call a
>> different API.
> IIRC on Windows there is no socket descriptor that can be used as a file
> descriptor. Seems reasonable to limit the implementation to standard file
> descriptors in this platform.
> Via the documentation of ReadFile: <
> hFile [in]
> A handle to the device (for example, a file, file stream, physical disk,
> volume, console buffer, tape drive, *socket*, communications resource,
> mailslot, or pipe). (...) For asynchronous read operations, hFile can be
> any handle that is opened with the FILE_FLAG_OVERLAPPED flag by
> the CreateFilefunction, or a *socket handle returned by
> the socket or accept function*.
> (emphasis mine).
> So, you can treat sockets as regular files in some contexts, and not in
> others. Of course there are other reasons to use WSARecv instead of
> ReadFile sometimes, which is why there are multiple functions.
handle != descriptor, and Python documentation explicitly says that socket
descriptor is limited, so it's ok to continue not supporting socket
descriptors for pipes.
> On *nix it really shouldn't be select. select cannot wait upon a file
>> descriptor whose *value* is greater than FD_SETSIZE, which means it sets
>> a hard (and small) limit on the number of things that a process which wants
>> to use this facility can be doing.
> I didn't know that. Should a note be added to
> http://docs.python.org/2/library/select ?
> The note that should be added there is simply "you should know how the
> select system call works in C if you want to use this module".
Why spreading FUD if it is possible to define a good entrypoint for those
who want to learn, but don't have enough time? Why not to say directly that
select interface is outdated?
> On the other hand, if you hard-code another arbitrary limit like this
>> into the stdlib subprocess module, it will just be another great reason why
>> Twisted's spawnProcess is the best and everyone should use it instead, so
>> be my guest ;-).
> spawnProcess requires a reactor. This PEP is an alternative for the
> proponents of green energy. =)
> Do you know what happens when you take something that is supposed to be
> happening *inside* a reactor, and then move it *outside* a reactor? It's
> not called "green energy", it's called "a bomb" ;-).
The biggest complain about nuclear physics is that to understand what's
going on it should have been gone 3D long ago. =) I think Twisted needs to
organize competition on the best visualization of underlying concepts. It
will help people grasp the concepts behind and different problems much
faster (as well as gain an ability to compare different reactors).
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-Dev