classification
Title: Popen Timeout raised on 3.6 but not on 3.8
Type: Stage:
Components: Versions: Python 3.8, Python 3.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Joan Prat Rigol, stestagg
Priority: normal Keywords:

Created on 2020-07-22 08:42 by Joan Prat Rigol, last changed 2020-07-23 12:50 by stestagg.

Messages (2)
msg374089 - (view) Author: Joan Prat Rigol (Joan Prat Rigol) Date: 2020-07-22 08:42
If I run this code in Python 3.8 I get the result as expected:

Python 3.8.2 (default, Apr 27 2020, 15:53:34) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
>>> process = subprocess.Popen("sudo -Si ls -l /home", shell=True, stdin=-1, stdout=-1, stderr=-1)
>>> out, err = process.communicate(input="Pr4tR1g01J04n\n".encode(), timeout=2)
>>> print(out)
b'total 4\ndrwxr-xr-x 43 joan joan 4096 Jul 22 09:46 joan\n'
>>> 
But If I run the code in Python 3.6 I am getting a timeout:

Python 3.6.9 (default, Apr 18 2020, 01:56:04) 
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
>>> process = subprocess.Popen("sudo -Si ls -l /home", shell=True, stdin=-1, stdout=-1, stderr=-1)
>>> out, err = process.communicate(input="Pr4tR1g01J04n\n".encode(), timeout=2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.6/subprocess.py", line 863, in communicate
    stdout, stderr = self._communicate(input, endtime, timeout)
  File "/usr/lib/python3.6/subprocess.py", line 1535, in _communicate
    self._check_timeout(endtime, orig_timeout)
  File "/usr/lib/python3.6/subprocess.py", line 891, in _check_timeout
    raise TimeoutExpired(self.args, orig_timeout)
subprocess.TimeoutExpired: Command 'sudo -Si ls -l /home' timed out after 2 seconds
>>> 
Is this a bug?
msg374134 - (view) Author: Steve Stagg (stestagg) Date: 2020-07-23 12:50
Joan, is that your *actual* password in the example code?  If so, I'd recommend changing it wherever you've used it.
History
Date User Action Args
2020-07-23 12:50:45stestaggsetnosy: + stestagg
messages: + msg374134
2020-07-22 08:42:59Joan Prat Rigolcreate