0

I am trying to import octave, but it timeouts; not always but most of the time. Is there any solution? How can i change the timeout-limit of the import command? In my script i have only the following line:

from oct2py import octave

I get the following error:

Traceback (most recent call last):
  File "test.py", line 2, in <module>
    from oct2py import octave
  File "/usr/local/lib/python2.7/site-packages/oct2py/__init__.py", line 38, in <module>
    octave = Oct2Py()
  File "/usr/local/lib/python2.7/site-packages/oct2py/core.py", line 76, in __init__
    self.restart()
  File "/usr/local/lib/python2.7/site-packages/oct2py/core.py", line 518, in restart
    logger=self.logger)
  File "/usr/local/lib/python2.7/site-packages/octave_kernel/kernel.py", line 173, in __init__
    self.repl = self._create_repl()
  File "/usr/local/lib/python2.7/site-packages/octave_kernel/kernel.py", line 391, in _create_repl
    force_prompt_on_continuation=True)
  File "/usr/local/lib/python2.7/site-packages/metakernel/replwrap.py", line 97, in __init__
    continuation_prompt_regex))
  File "/usr/local/lib/python2.7/site-packages/metakernel/replwrap.py", line 119, in set_prompt
    self.child.expect(prompt_regex)
  File "/usr/local/lib/python2.7/site-packages/pexpect/spawnbase.py", line 341, in expect
    timeout, searchwindowsize, async_)
  File "/usr/local/lib/python2.7/site-packages/pexpect/spawnbase.py", line 369, in expect_list
    return exp.expect_loop(timeout)
  File "/usr/local/lib/python2.7/site-packages/pexpect/expect.py", line 119, in expect_loop
    return self.timeout(e)
  File "/usr/local/lib/python2.7/site-packages/pexpect/expect.py", line 82, in timeout
    raise TIMEOUT(msg)
pexpect.exceptions.TIMEOUT: Timeout exceeded.
<pexpect.pty_spawn.spawn object at 0x7fbe43d8f910>
command: /usr/bin/octave-cli
args: ['/usr/bin/octave-cli', '--interactive', '--quiet', '--no-init-file']
buffer (last 100 chars): u''

after: <class 'pexpect.exceptions.TIMEOUT'>
match: None
match_index: None
exitstatus: None
flag_eof: False
pid: 2507
child_fd: 6
closed: False
timeout: 30
delimiter: <class 'pexpect.exceptions.EOF'>
logfile: None
logfile_read: None
logfile_send: None
maxread: 2000
ignorecase: False
searchwindowsize: None
delaybeforesend: 0.05
delayafterclose: 0.1
delayafterterminate: 0.1
searcher: searcher_re:
    0: re.compile(u'octave.*>')
Blckknght
  • 100,903
  • 11
  • 120
  • 169
  • Please add code where the exception is raised. – mahoriR Apr 06 '20 at 07:56
  • That's not an import timeout limit - there is no such limit. That looks like Octave taking so long to start that the `pexpect` module managing communications with Octave exceeds the configured timeout for waiting for the Octave prompt. – user2357112 Apr 06 '20 at 07:57
  • I don't know if it's a cause of your timeout issue, but have you considered upgrading your Python install to Python 3? As of the start of this year, Python 2 is no longer supported by its developers, and library developers are likely to be dropping support as well. – Blckknght Apr 06 '20 at 07:58
  • When i launch octave from the shell prompt it takes a long time to start, but it starts. I cannot upgrade to 3. I have to stick in 2.7 – cluster Apr 06 '20 at 08:03

1 Answers1

1

As OP mentioned, that exception is from oct2py, MonkeyPatching would be one of the way to solve this problem.

To try out the fix, you can go to following line of code and add timeout=None as param

In your local file system, /usr/local/lib/python2.7/site-packages/metakernel/replwrap.py Line 119.

Github link for same source here.

Looks like you are using pexpect which is raising Timeout.

As per documentation form pexpect, you can control the timeout behaviour -

child.expect(pexpect.EOF, timeout=None)
mahoriR
  • 4,377
  • 3
  • 18
  • 27