cluster
cluster

Reputation: 1

How can i change the import timeout limit (python2.7 and oct2py)

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.*>')

Upvotes: 0

Views: 342

Answers (1)

mahoriR
mahoriR

Reputation: 4597

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)

Upvotes: 1

Related Questions