From: Paul Wise Date: Wed, 5 Dec 2012 05:43:36 +0000 (+0800) Subject: Fix crash when running under python3. X-Git-Tag: iotop-0.6~21 X-Git-Url: https://repo.or.cz/w/iotop.git/commitdiff_plain/c819a5a033bf26fa7a90a627ac69e0d1891b0c43 Fix crash when running under python3. This reverts cd6ffb5913664844290f44a7ea48533caf8c459e Traceback (most recent call last): File "./iotop.py", line 12, in main() File "./iotop/iotop/ui.py", line 597, in main main_loop() File "./iotop/iotop/ui.py", line 587, in main_loop = lambda: run_iotop(options) File "./iotop/iotop/ui.py", line 485, in run_iotop return curses.wrapper(run_iotop_window, options) File "/usr/lib/python3.2/curses/wrapper.py", line 43, in wrapper return func(stdscr, *args, **kwds) File "./iotop/iotop/ui.py", line 478, in run_iotop_window ui.run() File "./iotop/iotop/ui.py", line 153, in run total = self.process_list.refresh_processes() File "./iotop/iotop/data.py", line 459, in refresh_processes self.processes.items() if File "./iotop/iotop/data.py", line 460, in process.update_stats()]) File "./iotop/iotop/data.py", line 358, in update_stats for tid, thread in self.threads.items(): RuntimeError: dictionary changed size during iteration [This is valid since 0fc4ab84c8cbba1fbe83dc71fb89100b87c54898 added the self.threads = dict(...)] --- diff --git a/iotop/data.py b/iotop/data.py index 84ac409..0e43a2c 100644 --- a/iotop/data.py +++ b/iotop/data.py @@ -356,9 +356,7 @@ class ProcessInfo(DumpableObject): def update_stats(self): stats_delta = Stats.build_all_zero() for tid, thread in self.threads.items(): - if thread.mark: - del self.threads[tid] - else: + if not thread.mark: stats_delta.accumulate(thread.stats_delta, stats_delta) self.threads = dict([(tid, thread) for tid, thread in self.threads.items() if not thread.mark])