[issue11459] Python select.select does not correctly report read readyness

2011-03-09 Thread Novimir Pablant

New submission from Novimir Pablant :

I am trying to get the output from an external program into python using 
`subprocess.Popen` and `select.select`.   For some reason though select.select 
is at times telling me that stdout is not ready to read, even when it is 
(reading from it works).   

This problem exists in python 3.1 & 3.2 but not in python 2.7.



For my particular application I am connecting to external program via ssh.  I 
would not expect that the ssh connection would be an issue.

The program that I am calling produces some output and eventually asks for user 
input.  In the example below I only get a portion of the output, then at some 
point select.select tells me that read is not available.  If I try to read 
anyway I can keep getting more output.  As soon as I press a key (passing 
something to stdin),  select.select tells me that I can read again and I get 
the rest of the output.   

Any ideas?


def wrapExternal(host=None):

   command = ["ssh", "-t", host, "some_program"]

   child = subprocess.Popen(command
,bufsize=0
,stdout=subprocess.PIPE
,stderr=subprocess.STDOUT)

   out = ''
   while True:
  r, w, x = select.select([child.stdout], [], [], 1.0)

  if child.poll() is not None:
 break

  if r:
 out = child.stdout.read(1)
 print(out.decode(), end='')
 sys.stdout.flush()

   return child.returncode

--
components: Library (Lib)
messages: 130488
nosy: amicitas
priority: normal
severity: normal
status: open
title: Python select.select does not correctly report read readyness
type: behavior
versions: Python 3.1, Python 3.2

___
Python tracker 
<http://bugs.python.org/issue11459>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11459] Python select.select does not correctly report read readyness

2011-03-09 Thread Novimir Pablant

Novimir Pablant  added the comment:

I forgot to mention, I am running on OS X 10.6.6.

--

___
Python tracker 
<http://bugs.python.org/issue11459>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11459] Python select.select does not correctly report read readyness

2011-03-10 Thread Novimir Pablant

Novimir Pablant  added the comment:

Applying the patch appears to fix this problem. Thanks!


I am definitely confused about why the buffer was changed to line buffered in 
the first place, especially since the default is bufsize=0 and the comment ("# 
Nearly unbuffered (XXX for now)") does not appear to match the actual behavior.

--

___
Python tracker 
<http://bugs.python.org/issue11459>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11459] Python select.select does not correctly report read readyness

2011-03-16 Thread Novimir Pablant

Novimir Pablant  added the comment:

I agree with Gregory that fixing this in 3.1 and 3.2 is the way to go. 

Otherwise I would suggest changing the documentation to match the behavior.

--

___
Python tracker 
<http://bugs.python.org/issue11459>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com