Stop msg polling on exception
To avoid growing error message stacks
@@ -45,15 +45,13 @@ class Runner:
self._state = None
self._proxy = None
+ self._polling_after_id = None
self._postponed_commands = []
self._check_alloc_console()
def start(self):
- try:
self.restart_backend()
- finally:
- self._poll_vm_messages()
def _init_commands(self):
get_workbench().add_command('run_current_script', "run", 'Run current script',
@@ -259,8 +257,8 @@ class Runner:
because event_generate across threads is not reliable
http://www.thecodingforums.com/threads/more-on-tk-event_generate-and-threads.359615/
"""
- try:
initial_state = self.get_state()
+ self._polling_after_id = None
while self._proxy is not None:
try:
@@ -301,8 +299,7 @@ class Runner:
if self.get_state() != initial_state:
self._send_postponed_commands()
- finally:
- get_workbench().after(50, self._poll_vm_messages)
+ self._polling_after_id = get_workbench().after(50, self._poll_vm_messages)
def _report_backend_crash(self, exc):
err = "Backend terminated (returncode: %s)\n" % exc.returncode
@@ -338,7 +335,14 @@ class Runner:
self._proxy = None
self._proxy = backend_class()
+ self._poll_vm_messages()
+
+
def destroy_backend(self):
+ if self._polling_after_id is not None:
+ get_workbench().after_cancel(self._polling_after_id)
+ self._polling_after_id = None
+
self._postponed_commands = []
if self._proxy:
self._proxy.destroy()
