-
Notifications
You must be signed in to change notification settings - Fork 147
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
ipdb.set_trace() breaks inspect #85
ipdb.set_trace() breaks inspect #85
Comments
Bringing across my most useful comment after I had dug into this issue: Sorry, fell off the radar. I've just dug into it, and I think the easiest sensible fix would be in ipdb. I fixed it in my local copy by making the set_trace() function look like this: def set_trace(frame=None):
update_stdout()
wrap_sys_excepthook()
if frame is None:
frame = sys._getframe().f_back
p = Pdb(def_colors)
p.set_trace(frame)
p.shell.restore_sys_module_state() The last line is the key bit - that will put Perhaps we shouldn't be replacing the |
ping @gotcha Any chance to look at this soon? Thanks! |
Released in https://pypi.python.org/pypi/ipdb/0.9.1 |
I met the same problem. my testcase was very simple, just set ipdb.set_trace() in the sub thread. i am not sure ipdb support multi-threaded debugging ? if __name__ == "__main__":
th1 = threading.Thread(target=printNum, args=(13,), name="thread_1")
th2 = threading.Thread(target=printNum, args=(10,), name="thread_2")
th1.start()
th2.start()
# wait until the sub thread return.
th1.join()
th2.join()
print("{0} ..the end...".format(threading.currentThread().getName()))
the function for the thread: def printNum(idx):
for num in range(idx):
# print the name of current running thread.
ipdb().set_trace() # --->failed.
print("{0}\tnum={1}".format(threading.current_thread().getName(), num))
logging.debug("(%s, %d)" % (threading.current_thread().getName(), num))
delay = math.ceil(random.random()*2)
time.sleep(delay) when debugging, it was failed. python test.py log: |
@hawkinchina You seem to bring same issue as #184. |
I find some info. about debugging with multi-thread.
|
I originally filed here: ipython/ipython#8671
If a script attempts to use inspect.getfile() on a class that was defined in a script file after set_trace() is called an exception is raised. Here's the traceback and the demo script.
I discovered that ipython is replacing sys.modules['main'] at some point (didn't get as far as pinpointing an exact line). This object ipython puts in there doesn't have attributes inspect is looking for which leads to the exception. It seems ipython could clean up after itself when set_trace() exits or copy those attributes to the replaced item.
I'd really like to get a work around so I can make a local modification until this fix goes out.
Version info
Python 2.7.10
Traceback
Script for reproduction
The text was updated successfully, but these errors were encountered: