Open
Description
BPO | 1705393 |
---|---|
Nosy | @amauryfa, @devdanzin |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee = None
closed_at = None
created_at = <Date 2007-04-22.20:38:27.000>
labels = ['easy', 'type-bug', '3.9', '3.10', '3.11', 'docs']
title = 'Document select() failure with buffered file'
updated_at = <Date 2021-12-05.16:59:15.125>
user = 'https://bugs.python.org/rongarret'
bugs.python.org fields:
activity = <Date 2021-12-05.16:59:15.125>
actor = 'iritkatriel'
assignee = 'docs@python'
closed = False
closed_date = None
closer = None
components = ['Documentation']
creation = <Date 2007-04-22.20:38:27.000>
creator = 'rongarret'
dependencies = []
files = []
hgrepos = []
issue_num = 1705393
keywords = ['easy']
message_count = 6.0
messages = ['31865', '31866', '31867', '84716', '85311', '116665']
nosy_count = 5.0
nosy_names = ['amaury.forgeotdarc', 'ggenellina', 'rongarret', 'ajaksu2', 'docs@python']
pr_nums = []
priority = 'normal'
resolution = None
stage = 'needs patch'
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue1705393'
versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']
Linked PRs
Metadata
Metadata
Assignees
Projects
Status
Todo
Activity
rongarret commentedon Apr 22, 2007
select.select fails on file-like objects created by socket.makefile when data exists in the file buffer but not in the underlying socket.
Here is code to reproduce the bug. Run it, then point a web browser at port 8080 and observer that select times out indicating that no input is available even though input is still in fact available.
=======
ggenellina commentedon Apr 23, 2007
The handler should not do its own select() call. (And even then, select should use the underlying socket, not the wrapping pseudo-file object).
Just removing the select() call works fine.
rongarret commentedon Apr 23, 2007
For this simple example yes, not for more complicated cases. My particular application is a transparent HTTP proxy which needs to be able to serve multiple connections at once and handle keep-alive connections. (The proxy connects to local server processes through unix sockets, which is why I can't use a regular HTTP proxy. Send me email if you want more details about why I'm doing this.) Without writing a full-blown HTTP-aware proxy, select (or something like it) is necessary.
Upon further study, though, I have come to the conclusion that this is not actually a bug (since select is doing what it is advertised to do), just very counter-intituitive behavior. If select is going to accept file objects as arguments it ought to do the Right Thing with them IMO.
devdanzin commentedon Mar 30, 2009
Cannot verify for trunk.
amauryfa commentedon Apr 3, 2009
This older post
http://bytes.com/groups/python/786579-python-2-2-1-select
describes a similar problem where select() is used on a buffered file
object (a pipe to another process)
IMO it should be documented that select() does not work so well for
objects which have a fileno(), but do data buffering: select() only sees
the file descriptor and cannot know whether there is data in the buffer.
BreamoreBoy commentedon Sep 17, 2010
I've changed things in reply to msg85311, feel free to alter things again if you disagree.
25 remaining items