Running python in child process

135 views
Skip to first unread message

Morten Enemark Lund

unread,
Jul 7, 2015, 3:29:54 PM7/7/15
to winpe...@googlegroups.com
Hi 

I have tried to start a python shell using winpexpect, but the process just seems to hang. Does anyone know the trick to get this working. 

winpexpect seems to be installed correctly. The different examples/tests with 'powershell' all work correctly. I am on python 3.4 on a windows 64 bit machine. 

However, when I attempt to start python itself in a child process it just hangs and eventually comes up with a timeout. 

The code looks like this:

import winpexpect
pe = winpexpect.winspawn('python.exe')
pe.expect('>>>')

Then it just hangs and get the following error below after some seconds. Can some tell me what I am doing wrong?

Traceback (most recent call last):
  File "C:\Users\mel\Anaconda3\lib\site-packages\winpexpect.py", line 541, in read_nonblocking
    handle, status, data = self.child_output.get(timeout=timeout)
  File "C:\Users\mel\Anaconda3\lib\queue.py", line 175, in get
    raise Empty
queue.Empty

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\mel\Anaconda3\lib\site-packages\pexpect.py", line 1378, in expect_loop
    c = self.read_nonblocking (self.maxread, timeout)
  File "C:\Users\mel\Anaconda3\lib\site-packages\winpexpect.py", line 543, in read_nonblocking
    raise TIMEOUT('Timeout exceeded in read_nonblocking().')
pexpect.TIMEOUT: Timeout exceeded in read_nonblocking().
Reply all
Reply to author
Forward
0 new messages