This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: socket timeout problems on Solaris
Type: behavior Stage: test needed
Components: Extension Modules, Library (Lib) Versions: Python 3.1, Python 3.2, Python 2.7
Status: closed Resolution: duplicate
Dependencies: Superseder: On Mac / BSD sockets returned by accept inherit the parent's FD flags
View: 7995
Assigned To: Nosy List: BreamoreBoy, astrand, movement, vila
Priority: normal Keywords:

Created on 2004-06-21 09:36 by astrand, last changed 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit
socketmodule.patch astrand, 2004-06-21 09:37 Suggested patch 1
Messages (3)
msg21231 - (view) Author: Peter Åstrand (astrand) * (Python committer) Date: 2004-06-21 09:36
The timeout stuff in the socket module does not work
correctly on Solaris. Here's a typical example:

import socket

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(("localhost", 9048))
conn, addr = s.accept()
print 'Connected by', addr
while 1:
    data = conn.recv(1024)
    if not data: break

When connecting, I get this traceback:

Connected by ('', 32866)
Traceback (most recent call last):
  File "", line 10, in ?
    data = conn.recv(1024)
socket.error: (11, 'Resource temporarily unavailable')

This is because Python treats the new socket object as
blocking (the timeout value is -1). However, in
Solaris, sockets returned from accept() inherits the
blocking property. So, because the listenting socket
was in non-blocking mode, the new connected socket will
be non-blocking as well. Since the timeout is -1,
internal_select will not call select. 

The solution to this problem is to explicitly set the
blocking mode on new socket objects. The attached patch
implements this. 
msg21232 - (view) Author: Peter Åstrand (astrand) * (Python committer) Date: 2004-06-21 12:20
Logged In: YES 

One workaround for this problem is:


Or, if you have the possibility, you can do
conn.setblocking(1) right after accept(). 
msg114334 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-08-19 07:20
Is this still a problem on Solaris?
Date User Action Args
2022-04-11 14:56:04adminsetgithub: 40424
2011-01-04 01:35:34pitrousetstatus: open -> closed
resolution: duplicate
superseder: On Mac / BSD sockets returned by accept inherit the parent's FD flags
nosy: astrand, movement, vila, BreamoreBoy
2010-08-19 07:20:54BreamoreBoysetnosy: + BreamoreBoy

messages: + msg114334
versions: + Python 3.1, Python 2.7, Python 3.2, - Python 2.6
2009-02-16 01:33:29movementsetnosy: + movement
2009-02-14 14:47:02ajaksu2setstage: test needed
type: behavior
components: + Extension Modules
versions: + Python 2.6, - Python 2.3
2008-01-05 14:15:42vilasetnosy: + vila
2004-06-21 09:36:13astrandcreate