[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2011-03-31 Thread Kristján Valur Jónsson
Kristján Valur Jónsson krist...@ccpgames.com added the comment: I can't see how that patch has anything to do with it. The problem has been present since at least 2.5. Your patch fixed it for timeout0.0 but left the 0.0 case still broken. It comes from these lines in init_sockobject: {

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2011-03-30 Thread Kristján Valur Jónsson
Kristján Valur Jónsson krist...@ccpgames.com added the comment: Please see issue 11721 where I was commenting on the same. I don't think the documentation makes it clear that socket.gettimeout() can be incorrect (i.e. return None when the socket is non-blocking). I also don't think there is a

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2011-03-30 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: I also don't think there is a portable way to detect the NBIO attribute of a socket, so we still have a case of socket.gettimeout() not accurately reflecting the blocking state of the socket Which case? I personally think that this logic

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2011-03-30 Thread Kristján Valur Jónsson
Kristján Valur Jónsson krist...@ccpgames.com added the comment: socket.defaulttimeout(None) s = socket.socket() s.settimeout(0) #nonblocking s.bind() s2, a = s.accept() print s2.gettimeout() #prints ´none´, meaning blocking s2.receive(10) #raises EWOULDBLOCK error, since internally it is

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2011-03-30 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: socket.defaulttimeout(None) s = socket.socket() s.settimeout(0) #nonblocking s.bind() s2, a = s.accept() print s2.gettimeout() #prints ´none´, meaning blocking s2.receive(10) #raises EWOULDBLOCK error, since internally it is non-blocking

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2011-03-30 Thread Daniel Stutzbach
Daniel Stutzbach stutzb...@google.com added the comment: I'm confused by the patch (ed0259230611). The patch comment and the NEWS item state the returned socket is now always non-blocking but the code change adds sock.setblocking(True). -- nosy: +stutzbach

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2011-03-30 Thread Kristján Valur Jónsson
Kristján Valur Jónsson krist...@ccpgames.com added the comment: Antoine, absolument. Please see attached file bug.py As for a different patch, we should agree what behaviour should be expected. I don't think it is possible to rely on some platform specific behaviour. This is because it is

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2011-03-30 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Antoine, absolument. Please see attached file bug.py Ah, thanks, I see. But this is not caused by this issue. It seems to come from 12442ac3f7dd. Instead we should simply define it for python, and in accordance to established tradition,

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2011-01-05 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Ok, here is a patch which prefers the default timeout (if set) over fixing of inherited flags. Tested under Linux, Windows, OpenSolaris. -- Added file: http://bugs.python.org/file20278/nonblock3.patch

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2011-01-05 Thread Martin v . Löwis
Martin v. Löwis mar...@v.loewis.de added the comment: Ok, here is a patch which prefers the default timeout (if set) over fixing of inherited flags. Tested under Linux, Windows, OpenSolaris. This patch looks fine to me. Please also update the accept documentation to explain the situation

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2011-01-05 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Ok, I committed the patch in r87768 and overhauled the timeout docs in r87769. I'm not sure this should be backported (because of the very slight behaviour change), so I'm closing. -- keywords: -needs review resolution: - fixed stage:

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2011-01-04 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: A new patch combining Ross' test with the simple approach from issue 976613. Works under Linux, OpenSolaris and Windows. -- Added file: http://bugs.python.org/file20257/nonblock2.patch ___ Python

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2011-01-04 Thread Martin v . Löwis
Martin v. Löwis mar...@v.loewis.de added the comment: I think this patch (nonblock2.patch) is wrong. If I have a non-blocking server socket on *BSD, and do accept, with no default timeout: IIUC, under the patch, I will get a blocking connection socket. However, according to the operating

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2011-01-04 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: I think this patch (nonblock2.patch) is wrong. If I have a non-blocking server socket on *BSD, and do accept, with no default timeout: IIUC, under the patch, I will get a blocking connection socket. However, according to the operating system

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2011-01-04 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Antoine Pitrou pit...@free.fr added the comment: I think this patch (nonblock2.patch) is wrong. If I have a non-blocking server socket on *BSD, and do accept, with no default timeout: IIUC, under the patch, I will get a blocking

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2011-01-04 Thread Martin v . Löwis
Martin v. Löwis mar...@v.loewis.de added the comment: Well, either the defaulttimeout should have the priority over the parent socket's settings (your argument in msg125135), or it shouldn't. I'm fine with both, but I think any more complicated combination would end up puzzling for the user

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2011-01-03 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: I like the logic of Antoine's patch much better (basing this on whether the listening socket had a timeout). I wonder whether it's correct though if there is a defaulttimeout: shouldn't it then leave the timeout on the socket instead? Indeed,

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2011-01-03 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Issue 976613 (duplicate) has a very simple patch, will see if it's sufficient. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7995 ___

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2011-01-02 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: I've tried the patch under OpenSolaris and the test fails (EAGAIN), meaning that accept() semantics there are the same as under BSD: == ERROR: testInheritFlags

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2011-01-02 Thread Ross Lagerwall
Ross Lagerwall rosslagerw...@gmail.com added the comment: OK try this one, it's now opt-out. -- Added file: http://bugs.python.org/file20222/7995_v3.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7995

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2011-01-02 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: After further testing, it turns out that Windows exhibits BSD-like behaviour too. So instead of complicating the flag-setting code again, I suggest an alternative of doing it in the Python wrapper. Patch attached. -- Added file:

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2011-01-02 Thread Martin v . Löwis
Martin v. Löwis mar...@v.loewis.de added the comment: I like the logic of Antoine's patch much better (basing this on whether the listening socket had a timeout). I wonder whether it's correct though if there is a defaulttimeout: shouldn't it then leave the timeout on the socket instead?

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2010-12-31 Thread Ross Lagerwall
Ross Lagerwall rosslagerw...@gmail.com added the comment: issue1515839 seems to be a duplicate of this one. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7995 ___

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2010-12-31 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Thanks for the patch. Comments/questions: - please don't use C++-style comments (//) in C code; some compilers can choke on them - should the code path be also enabled for netbsd? (or other variants?) - why does the test silence socket.error on

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2010-12-31 Thread Ross Lagerwall
Ross Lagerwall rosslagerw...@gmail.com added the comment: From what I coud see, the same applied to NetBSD so I enabled it for NetBSD as well - if there are any other OSes that need it enabled, they can be added. The updated patch checks for fcntl() failing and simply leaves the socket as is

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2010-12-30 Thread Ross Lagerwall
Ross Lagerwall rosslagerw...@gmail.com added the comment: Attached is a patch (the original one in patch form) against py3k with unit test. It seems to work well - tested on Linux FreeBSD. -- keywords: +patch nosy: +rosslagerwall Added file:

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2010-11-22 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Well, unless someone explains convincingly how the current behaviour is desireable (rather than misleading and useless), I really think this is a bug that should be fix (then we can also discuss what the fix should exactly be). So

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2010-11-21 Thread Ned Deily
Ned Deily n...@acm.org added the comment: (See also Issue7322) -- nosy: +ned.deily ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7995 ___ ___

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2010-11-21 Thread Roy Smith
Roy Smith r...@panix.com added the comment: The answer depends on what the socket module is trying to do. Is the goal simply to provide a pythonic thin wrapper over the underlying OS interfaces without altering their semantics, or to provide a completely homogeneous abstraction? Having

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2010-11-21 Thread Antoine Pitrou
Changes by Antoine Pitrou pit...@free.fr: -- nosy: +exarkun ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7995 ___ ___ Python-bugs-list mailing

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2010-11-21 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Oh, and a test should be added of course. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7995 ___

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2010-11-21 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: It seems to me that it's a reasonable request. There is indeed a bug, since Python uses non-blocking sockets to implement its timeout feature, and flags inheritance means Python's view of whether the socket is non-blocking is not in sync with

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2010-11-21 Thread Martin v . Löwis
Martin v. Löwis mar...@v.loewis.de added the comment: The answer depends on what the socket module is trying to do. Is the goal simply to provide a pythonic thin wrapper over the underlying OS interfaces without altering their semantics, or to provide a completely homogeneous abstraction?

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2010-11-21 Thread Justin Cappos
Justin Cappos justincap...@gmail.com added the comment: Apparently, the designers of BSD thought differently. Remember that it is them who defined the socket API in the first place, so they have the right that their design decisions are considered. I think there is a bit of confusion here.

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2010-11-21 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Anyway, my personal opinion is that we should consider the current behavior a bug and fix it. I like the idea of setting all accepted sockets to blocking mode (and documenting it clearly). -1. I think it is what most people would

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2010-11-21 Thread Martin v . Löwis
Martin v. Löwis mar...@v.loewis.de added the comment: Here is the issue (put plainly): Unfortunately, I still don't understand it. I go through your plain elaboration below. Python sockets support a notion of timeout (note this notion is not reflected in the OS socket API). Correct. The

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2010-11-21 Thread Martin v . Löwis
Martin v. Löwis mar...@v.loewis.de added the comment: We are talking about the timeout feature, which is a Python feature, not a BSD (or Linux) sockets feature. It should work properly, even if that means adding some boilerplate around system calls. I agree that the semantics of the socket

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2010-11-21 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Le dimanche 21 novembre 2010 à 20:16 +, Martin v. Löwis a écrit : We are talking about the timeout feature, which is a Python feature, not a BSD (or Linux) sockets feature. It should work properly, even if that means adding some

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2010-11-21 Thread Justin Cappos
Justin Cappos justincap...@gmail.com added the comment: This implementation assumes that the OS sets any socket it receives via accept to nonblocking. (this is a false assumption on BSD) Not true. It doesn't assume that (it doesn't assume the reverse, either). The Python implementation

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2010-11-21 Thread Martin v . Löwis
Martin v. Löwis mar...@v.loewis.de added the comment: Well, I don't think setting a timeout on a listening socket and then expecting the socket received through accept() to be non-blocking (but only on BSD) is a legitimate application. Right. But setting the server socket to nonblocking, and

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2010-11-21 Thread Justin Cappos
Justin Cappos justincap...@gmail.com added the comment: Well, I don't think setting a timeout on a listening socket and then expecting the socket received through accept() to be non-blocking (but only on BSD) is a legitimate application. Right. But setting the server socket to

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2010-11-21 Thread Martin v . Löwis
Martin v. Löwis mar...@v.loewis.de added the comment: The Python implementation sets timeout=None (which implies that the underlying socket is blocking). No, it doesn't. A socket may be non-blocking without having a timeout; that's the socket API (on all systems, not just BSD). The problem

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2010-11-21 Thread Martin v . Löwis
Martin v. Löwis mar...@v.loewis.de added the comment: However, I hope we can all agree that having the Python socket object in a different blocking / non-blocking state than the OS socket descriptor is wrong. This is what needs to be fixed. Ok, now I see where your misunderstanding is: you

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2010-11-21 Thread Roy Smith
Roy Smith r...@panix.com added the comment: I got into this by starting with Issue7322, which reports a scenario where data is lost using makefile(). The docs for makefile() say, The socket must be in blocking mode (it can not have a timeout). So, we've got published documentation which

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2010-11-21 Thread Martin v . Löwis
Martin v. Löwis mar...@v.loewis.de added the comment: I got into this by starting with Issue7322, which reports a scenario where data is lost using makefile(). The docs for makefile() say, The socket must be in blocking mode (it can not have a timeout). So, we've got published documentation

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2010-11-21 Thread Ned Deily
Ned Deily n...@acm.org added the comment: The notes in the documentation under socket.gettimeout() do go into more detail than elsewhere. But at least one thing there is at best misleading: Sockets are always created in blocking mode is, as we've seen, not correct for BSD-ish systems for

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2010-11-21 Thread Roy Smith
Roy Smith r...@panix.com added the comment: Responding to msg122013: I think he exactly meant to equate the two. The original problem described in issue882297 is that the makefile() documentation only stated that the socket could not be in non-blocking mode. The test case presented didn't

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2010-11-21 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: The notes in the documentation under socket.gettimeout() do go into more detail than elsewhere. But at least one thing there is at best misleading: Sockets are always created in blocking mode is, as we've seen, not correct for BSD-ish systems

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2010-11-21 Thread Justin Cappos
Justin Cappos justincap...@gmail.com added the comment: The Python implementation sets timeout=None (which implies that the underlying socket is blocking). No, it doesn't. A socket may be non-blocking without having a timeout; that's the socket API (on all systems, not just BSD). Sure and

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2010-11-21 Thread Martin v . Löwis
Martin v. Löwis mar...@v.loewis.de added the comment: Well, unless someone explains convincingly how the current behaviour is desireable (rather than misleading and useless), I really think this is a bug that should be fix (then we can also discuss what the fix should exactly be). So please

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2010-11-21 Thread Martin v . Löwis
Martin v. Löwis mar...@v.loewis.de added the comment: Set blocking or non-blocking mode of the socket: if flag is 0, the socket is set to non-blocking, else to blocking mode. This seems to imply that timeout = None - blocking. I see. So gettimeout() should really make a system call, to

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2010-03-07 Thread Ronald Oussoren
Ronald Oussoren ronaldousso...@mac.com added the comment: I've removed 2.5 and added 3.2 because there won't be further bugfix releases of 2.5 and the issue also affects 3.2. IMHO changing this behavior is not a bugfix and is therefore out of scope for 2.6.x, in particular because this change

[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2010-02-22 Thread Justin Cappos
New submission from Justin Cappos justincap...@gmail.com: Suppose there is a program that has a listening socket that calls accept to obtain new sockets for client connections. socketmodule.c assumes that these client sockets have timeouts / blocking in the default state for new sockets