We are having a problem debugging our application using the pydev debugger. We have a application that creates and destroy threads and when a break point is set in the main thread we occasionally get the following exception
File "C:\eclipse\plugins\org.python.pydev.debug_1.6.3.2010100513\pysrc\pydevd_frame.py", line 102, in trace_dispatch
self.doWaitSuspend(thread, frame, event, arg)
File "C:\eclipse\plugins\org.python.pydev.debug_1.6.3.2010100513\pysrc\pydevd_frame.py", line 25, in doWaitSuspend
self._args.doWaitSuspend(*args, **kwargs)
File "C:\eclipse\plugins\org.python.pydev.debug_1.6.3.2010100513\pysrc\pydevd.py", line 687, in doWaitSuspend
self.processInternalCommands()
File "C:\eclipse\plugins\org.python.pydev.debug_1.6.3.2010100513\pysrc\pydevd.py", line 399, in processInternalCommands for tId in self.RUNNING_THREAD_IDS.keys():
RuntimeError: dictionary changed size during iteration
From the code I am assuming this is being caused by one of our background threads being destroyed changing the self.RUNNING_THREAD_IDS to change.
Has anyone else ran into this? If this is a bug in the debbuger code does anyone know the issue so I can monitor it.? And last is there a recommend work around/code change for this.
Thanks
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I encounter this too with my version is " PyDev for Eclipse 2.1.0.2011052613" running on Ubuntu.
If you look in this version at pydevd.py on line 404, you have:
for tId in self.RUNNING_THREAD_IDS.keys():
try:
if not DictContains(foundThreads, tId):
self.processThreadNotAlive(tId)
except:
sys.stderr.write('Error iterating through %s (%s) - %s\n' % (foundThreads, foundThreads.__class__, dir(foundThreads)))
raise
processThreadNotAlive is the method that modifies RUNNING_THREAD_IDS.
They need to fix this by either making a copy of that list and iterate over that, or make a list of thread id's that we want to delete, and delete them after this loop iteration.
You can't change this list while iterating over it.
I'm going to patch it tonight and test it.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
@@ -400,7 +401,8 @@
if hasattr(t, 'doKill'):
t.doKill()
- for tId in self.RUNNING_THREAD_IDS.keys():
+ runningThreadsCopy = copy.copy(self.RUNNING_THREAD_IDS)
+ for tId in runningThreadsCopy.keys():
try:
if not DictContains(foundThreads, tId):
self.processThreadNotAlive(tId)
cheers,
Darrell.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
We are having a problem debugging our application using the pydev debugger. We have a application that creates and destroy threads and when a break point is set in the main thread we occasionally get the following exception
File "C:\eclipse\plugins\org.python.pydev.debug_1.6.3.2010100513\pysrc\pydevd_frame.py", line 102, in trace_dispatch
self.doWaitSuspend(thread, frame, event, arg)
File "C:\eclipse\plugins\org.python.pydev.debug_1.6.3.2010100513\pysrc\pydevd_frame.py", line 25, in doWaitSuspend
self._args.doWaitSuspend(*args, **kwargs)
File "C:\eclipse\plugins\org.python.pydev.debug_1.6.3.2010100513\pysrc\pydevd.py", line 687, in doWaitSuspend
self.processInternalCommands()
File "C:\eclipse\plugins\org.python.pydev.debug_1.6.3.2010100513\pysrc\pydevd.py", line 399, in processInternalCommands
for tId in self.RUNNING_THREAD_IDS.keys():
RuntimeError: dictionary changed size during iteration
From the code I am assuming this is being caused by one of our background threads being destroyed changing the self.RUNNING_THREAD_IDS to change.
Has anyone else ran into this? If this is a bug in the debbuger code does anyone know the issue so I can monitor it.? And last is there a recommend work around/code change for this.
Thanks
What's your Python version?
Cheers,
Fabio
I encounter this too with my version is " PyDev for Eclipse 2.1.0.2011052613" running on Ubuntu.
If you look in this version at pydevd.py on line 404, you have:
for tId in self.RUNNING_THREAD_IDS.keys():
try:
if not DictContains(foundThreads, tId):
self.processThreadNotAlive(tId)
except:
sys.stderr.write('Error iterating through %s (%s) - %s\n' % (foundThreads, foundThreads.__class__, dir(foundThreads)))
raise
processThreadNotAlive is the method that modifies RUNNING_THREAD_IDS.
They need to fix this by either making a copy of that list and iterate over that, or make a list of thread id's that we want to delete, and delete them after this loop iteration.
You can't change this list while iterating over it.
I'm going to patch it tonight and test it.
This patch seemed to work for me…
-- pydevd.py.old 2011-06-29 10:15:43.463040992 -0400
+++ pydevd.py 2011-06-29 10:13:00.154231186 -0400
@@ -52,6 +52,7 @@
import pydevd_io
from pydevd_additional_thread_info import PyDBAdditionalThreadInfo
import time
+import copy
threadingEnumerate = threading.enumerate
threadingCurrentThread = threading.currentThread
@@ -400,7 +401,8 @@
if hasattr(t, 'doKill'):
t.doKill()
- for tId in self.RUNNING_THREAD_IDS.keys():
+ runningThreadsCopy = copy.copy(self.RUNNING_THREAD_IDS)
+ for tId in runningThreadsCopy.keys():
try:
if not DictContains(foundThreads, tId):
self.processThreadNotAlive(tId)
cheers,
Darrell.
I'm sorry I didn't answer on this thread, but this should be already fixed for PyDev 2.2 (see release notes at: http://pydev.org/)
Cheers,
Fabio
p.s.: If the current release doesn't work for you, please let me know.