Issue2615

classification
Title: select.select using subprocess.Popen error
Type: behaviour Severity: critical
Components: Library Versions: Jython 2.7
Milestone:
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Brian Kurt, amak, zyasoft
Priority: Keywords:

Created on 2017-08-21.12:29:59 by Brian Kurt, last changed 2017-09-05.23:00:38 by zyasoft.

Messages
msg11540 (view) Author: Brian Phalane (Brian Kurt) Date: 2017-08-21.12:29:57
Hi, i am experiencing an issue while trying shipping my python script to jython. The script work perfect running with python . however, i get the below running in Jython standalone jar 2.7.* 


logs = select.select(reads,[],[])   File "filepath/jython-standalone-2.7.0.jar/Lib/_socket.py", line 1468, in select   File "/filepath/jython-standalone-2.7.0.jar/Lib/_socket.py", line 410, in __call__   File "/home/A230754/Documents/DevOps/liquibase-client/jython-standalone-2.7.0.jar/Lib/contextlib.py", line 17, in __enter__   File "/home/A230754/Documents/DevOps/liquibase-client/jython-standalone-2.7.0.jar/Lib/contextlib.py", line 17, in __enter__   File "/home/A230754/Documents/DevOps/liquibase-client/jython-standalone-2.7.0.jar/Lib/_socket.py", line 402, in _register_sockets   File "/home/A230754/Documents/DevOps/liquibase-client/jython-standalone-2.7.0.jar/Lib/_socket.py", line 390, in _normalize_sockets _socket.error: [Errno 9] Bad file descriptor: org.python.core.io.StreamIO@3ba348ca

tried various methods and still not succeeding. to a point i thought this is a bug.

my code

  myfile =open('file_path.log','w',0)
            
            p=Popen(["bash","file.sh",var1,var2,var3,var4],stdout=subprocess.PIPE,stderr=subprocess.PIPE)
            
            p.wait()
            
            
            stdout= []
            stderr= []
           
            
            
        while True:
            
            #reading the output and standard error output from subprocess and background process(liquibase_logs)
            reads = [p.stdout.fileno()]
            
            
            #The select system call to wait until ready for reading,wait until ready for writing,wait for an exceptional condition
            
            logs = select.select(reads,[],[])
             
            #iterate through logs
            for fd in logs[0]:
                if fd == p.stdout.fileno():
                    read = p.stdout.readline()
                    sys.stdout.write('stdout: ' + read)
                    stdout.append(read)
                #if fd == p.stderr.fileno():
                  #  read = p.stderr.readline()
                  #  sys.stderr.write('stderr: ' + read)
                   # stderr.append(read)
       
          
            if p.poll() != None:
                
                break
msg11571 (view) Author: Jim Baker (zyasoft) Date: 2017-09-05.23:00:38
Sorry, we do not support selectable stdin/stdout - see #1778, which this bug duplicates.

I know that JRuby worked around this, but not without significant work on their part.
History
Date User Action Args
2017-09-05 23:00:38zyasoftsetnosy: + zyasoft
messages: + msg11571
2017-08-25 16:36:23amaksetnosy: + amak
2017-08-21 12:29:59Brian Kurtcreate