Skip to content

infinite loop  #11026

Closed
Closed

Description

@kmike

When I try to execute this code: https://gist.github.com/kmike/91ef29a3fd2b94ff8b47a5a9ebfa7be2 in an IPython cell (both terminal and notebook), IPython goes to an infinite loop. Code just defines a nested dict; there are unicode symbols. Here is the traceback on interruption:

ERROR:tornado.general:Uncaught exception in ZMQStream callback
Traceback (most recent call last):
  File "/Users/kmike/envs/deep-deep/lib/python3.6/site-packages/zmq/eventloop/zmqstream.py", line 432, in _run_callback
    callback(*args, **kwargs)
  File "/Users/kmike/envs/deep-deep/lib/python3.6/site-packages/tornado/stack_context.py", line 277, in null_wrapper
    return fn(*args, **kwargs)
  File "/Users/kmike/envs/deep-deep/lib/python3.6/site-packages/ipykernel/kernelbase.py", line 283, in dispatcher
    return self.dispatch_shell(stream, msg)
  File "/Users/kmike/envs/deep-deep/lib/python3.6/site-packages/ipykernel/kernelbase.py", line 233, in dispatch_shell
    handler(stream, idents, msg)
  File "/Users/kmike/envs/deep-deep/lib/python3.6/site-packages/ipykernel/kernelbase.py", line 399, in execute_request
    user_expressions, allow_stdin)
  File "/Users/kmike/envs/deep-deep/lib/python3.6/site-packages/ipykernel/ipkernel.py", line 208, in do_execute
    res = shell.run_cell(code, store_history=store_history, silent=silent)
  File "/Users/kmike/envs/deep-deep/lib/python3.6/site-packages/ipykernel/zmqshell.py", line 537, in run_cell
    return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
  File "/Users/kmike/envs/deep-deep/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2654, in run_cell
    cell = self.input_transformer_manager.transform_cell(raw_cell)
  File "/Users/kmike/envs/deep-deep/lib/python3.6/site-packages/IPython/core/inputsplitter.py", line 659, in transform_cell
    self.push(cell)
  File "/Users/kmike/envs/deep-deep/lib/python3.6/site-packages/IPython/core/inputsplitter.py", line 702, in push
    out = self.push_line(line)
  File "/Users/kmike/envs/deep-deep/lib/python3.6/site-packages/IPython/core/inputsplitter.py", line 729, in push_line
    line = self.assemble_python_lines.push(line)
  File "/Users/kmike/envs/deep-deep/lib/python3.6/site-packages/IPython/core/inputtransformer.py", line 138, in push
    for intok in self.tokenizer:
  File "/Users/kmike/envs/deep-deep/lib/python3.6/site-packages/IPython/utils/tokenize2.py", line 508, in _tokenize
    pseudomatch = pseudoprog.match(line, pos)
KeyboardInterrupt

I have latest ipython[notebook] installed, with all dependencies upgraded as well.

Activity

  1. takluyver commented on Mar 1, 2018

    @takluyver
    Member

    It's not actually infinite, just very slow. There's some code in current released versions that's O(N^2) on the number of lines in an executed cell. #10898 improves on this, but hasn't been released yet.

    Even in master, it takes a while to execute, though. IPython is not a good environment for running very long pieces of code, because we have to go through the code to identify and transform IPython special syntax (%magic and !system commands and so on). We may be able to make that more efficient, but it's probably always going to be slower than putting it in a .py file and using from currency_data import CURRENCIES.

  2. kmike commented on Mar 1, 2018

    @kmike
    ContributorAuthor

    Should I close this ticket as a duplicate?

  3. takluyver commented on Mar 1, 2018

    @takluyver
    Member

    I'm going to try to find time to look into it some more, because even in master it's unreasonably slow (25 seconds on my computer).

  4. takluyver commented on Mar 11, 2018

    @takluyver
    Member

    #11041 completely replaces the input transformation machinery, and brings this case up to a reasonable speed. If we go with that, it will probably be fixed in IPython 7.0.

  5. added this to the 7.0 milestone on Mar 29, 2018
  6. Carreau commented on Sep 6, 2018

    @Carreau
    Member

    On master that is now fixed, your example is ~quasi instantaneous for me. Closing. Hopping for 7.0 in a few weeks.

  7. kmike commented on Sep 6, 2018

    @kmike
    ContributorAuthor

    Awesome, thanks @takluyver and @Carreau!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions