Commits

Senthil Kumaran committed 94fde9c

main_loop.py

Comments (0)

Files changed (1)

         """
         Call all the registered idle callbacks.
         """
-        for callback in self._idle_callbacks.values():
+        for callback in list(self._idle_callbacks.values()):
             callback()
 
     def run(self):
             while True:
                 try:
                     self._loop()
-                except select.error, e:
+                except select.error as e:
                     if e.args[0] != 4:
                         # not just something we need to retry
                         raise
         """
         A single iteration of the event loop
         """
-        fds = self._watch_files.keys()
+        fds = list(self._watch_files.keys())
         if self._alarms or self._did_something:
             if self._alarms:
                 tm = self._alarms[0][0]
             self._glib_idle_enabled = True
 
         def _glib_idle_callback(self):
-            for callback in self._idle_callbacks.values():
+            for callback in list(self._idle_callbacks.values()):
                 callback()
             self._glib_idle_enabled = False
             return False # ask glib not to call again (or we would be called
                 # An exception caused us to exit, raise it now
                 exc_info = self._exc_info
                 self._exc_info = None
-                raise exc_info[0], exc_info[1], exc_info[2]
+                raise exc_info[0](exc_info[1]).with_traceback(exc_info[2])
 
         def handle_exit(self,f):
             """
             self._twisted_idle_enabled = True
 
         def _twisted_idle_callback(self):
-            for callback in self._idle_callbacks.values():
+            for callback in list(self._idle_callbacks.values()):
                 callback()
             self._twisted_idle_enabled = False
 
                 # An exception caused us to exit, raise it now
                 exc_info = self._exc_info
                 self._exc_info = None
-                raise exc_info[0], exc_info[1], exc_info[2]
+                raise exc_info[0](exc_info[1]).with_traceback(exc_info[2])
 
         def handle_exit(self, f, enable_idle=True):
             """
                         self.reactor.stop()
                 except:
                     import sys
-                    print sys.exc_info()
+                    print(sys.exc_info())
                     self._exc_info = sys.exc_info()
                     if self.manage_reactor:
                         self.reactor.crash()
             args = ", ".join([repr(a) for a in argl])
             if args and argd:
                 args = args + ", "
-            args = args + ", ".join([k+"="+repr(v) for k,v in argd.items()])
-            print self._name+"("+args+")"
+            args = args + ", ".join([k+"="+repr(v) for k,v in list(argd.items())])
+            print(self._name+"("+args+")")
             if exit:
                 raise ExitMainLoop()
             return self._rval