Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autoreload hang for changed instance methods: between 7.5.0 and 7.8.0 #11885

Closed
histed opened this issue Sep 14, 2019 · 3 comments
Closed

autoreload hang for changed instance methods: between 7.5.0 and 7.8.0 #11885

histed opened this issue Sep 14, 2019 · 3 comments

Comments

@histed
Copy link

histed commented Sep 14, 2019

Possible autoreload regression in ipython 7.8.0 and jupyterlab 1.0+

With %autoreload 2, when I change a method in a source file when holding an existing instance object in memory, autoreload used to reload the changed instance code just fine. (It didn't find new methods, which required an explicit imp.reload(), but that's ok.)

With ipython 7.8.0, changing code in a method causes the kernel to hang when autoreload triggered by cell execute. Interrupting kernel gives following traceback

[autoreload of testcase failed: Traceback (most recent call last):
  File "/Users/histed/anaconda37/envs/mh37b/lib/python3.7/site-packages/IPython/extensions/autoreload.py", line 245, in check
    superreload(m, reload, self.old_objects)
  File "/Users/histed/anaconda37/envs/mh37b/lib/python3.7/site-packages/IPython/extensions/autoreload.py", line 450, in superreload
    update_generic(old_obj, new_obj)
  File "/Users/histed/anaconda37/envs/mh37b/lib/python3.7/site-packages/IPython/extensions/autoreload.py", line 387, in update_generic
    update(a, b)
  File "/Users/histed/anaconda37/envs/mh37b/lib/python3.7/site-packages/IPython/extensions/autoreload.py", line 357, in update_class
    update_instances(old, new)
  File "/Users/histed/anaconda37/envs/mh37b/lib/python3.7/site-packages/IPython/extensions/autoreload.py", line 312, in update_instances
    update_instances(old, new, obj.__dict__, visited)
  File "/Users/histed/anaconda37/envs/mh37b/lib/python3.7/site-packages/IPython/extensions/autoreload.py", line 317, in update_instances
    update_instances(old, new, obj, visited)
  File "/Users/histed/anaconda37/envs/mh37b/lib/python3.7/site-packages/IPython/extensions/autoreload.py", line 317, in update_instances
    update_instances(old, new, obj, visited)
  File "/Users/histed/anaconda37/envs/mh37b/lib/python3.7/site-packages/IPython/extensions/autoreload.py", line 317, in update_instances
    update_instances(old, new, obj, visited)
  File "/Users/histed/anaconda37/envs/mh37b/lib/python3.7/site-packages/IPython/extensions/autoreload.py", line 315, in update_instances
    if hasattr(obj, 'items') or (hasattr(obj, '__contains__')
KeyboardInterrupt
]

testcase.py:

class Class1:
    def __init__(self):
        print(0)

    def method(self):
        print(1)
        #print(2)

In a notebook, run:

import testcase

c = testcase.Class1()
c.method()

Then change method() by commenting/uncommenting print(2). Then run

c.method()

And kernel hangs.

@histed
Copy link
Author

histed commented Sep 14, 2019

may be related to #11644 @daharn @Carreau worked on

@Naikless
Copy link
Contributor

Naikless commented Sep 14, 2019

Should be solved in 7.9 or if you use the latest git version.

@histed
Copy link
Author

histed commented Sep 14, 2019

confirm: latest master on github fixes this.

@histed histed closed this as completed Sep 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants