Fix yet another crash on shutdown.

Properly shut down ProjectView when quitting the app.
looper
Ben Niemann 5 years ago
parent 77e0805b29
commit 5d91a0112a

@ -218,30 +218,6 @@ Traceback (most recent call last):
raise NotListMemberError(self.id)
noisicaa.core.model_base.NotListMemberError: 32e1b62e20524d16a584c65311960356
* Exception on shutdown :CRASH:
Traceback (most recent call last):
File "/storage/users/pink/projects/noisicaä/noisicaa/core/process_manager.py", line 236, in start_process
rc = impl.main(ready_callback)
File "/storage/users/pink/projects/noisicaä/noisicaa/core/process_manager.py", line 386, in main
self.main_async(ready_callback, *args, **kwargs))
File "/usr/lib/python3.5/asyncio/base_events.py", line 387, in run_until_complete
return future.result()
File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result
raise self._exception
File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
result = coro.send(None)
File "/storage/users/pink/projects/noisicaä/noisicaa/core/process_manager.py", line 409, in main_async
await self.cleanup()
File "/storage/users/pink/projects/noisicaä/noisicaa/music/project_process.py", line 225, in cleanup
await self.node_db.cleanup()
File "/storage/users/pink/projects/noisicaä/noisicaa/node_db/client.py", line 34, in cleanup
await self.disconnect()
File "/storage/users/pink/projects/noisicaä/noisicaa/node_db/client.py", line 46, in disconnect
await self._stub.call('END_SESSION', self._session_id)
File "/storage/users/pink/projects/noisicaä/noisicaa/core/ipc.py", line 357, in call
raise ConnectionClosed
noisicaa.core.ipc.ConnectionClosed
* when changing scale_x, keep view centered on current position :FR:
* clarify time handling :CLEANUP:
- musical time

@ -160,7 +160,10 @@ class AudioProcProcessMixin(object):
self.sessions = {}
async def cleanup(self):
logger.info("Cleaning up AudioProcProcess %s...", self.name)
for session in self.sessions.values():
logger.info("Cleaning up session %s...", session.id)
session.cleanup()
self.sessions.clear()
@ -169,10 +172,12 @@ class AudioProcProcessMixin(object):
self.shm = None
if self.__vm is not None:
logger.info("Cleaning up VM...")
self.__vm.cleanup()
self.__vm = None
if self.__host_data is not None:
logger.info("Cleaning up HostData...")
self.__host_data.cleanup()
self.__host_data = None

@ -464,6 +464,11 @@ class ProcessManager(object):
rc = impl.main(child_connection)
for thread in threading.enumerate():
if thread.ident == threading.get_ident():
continue
logger.warning("Left over thread %s (%d)", thread.name, thread.ident)
except SystemExit as exc:
rc = exc.code
except: # pylint: disable=bare-except
@ -658,8 +663,12 @@ class ProcessImpl(object):
return self.event_loop.run_until_complete(
self.main_async(child_connection, *args, **kwargs))
finally:
logger.info("Closing event loop...")
self.event_loop.stop()
self.event_loop.run_until_complete(
asyncio.gather(*asyncio.Task.all_tasks(self.event_loop)))
self.event_loop.close()
logger.info("Event loop closed.")
async def main_async(self, child_connection, *args, **kwargs):
self.manager = ManagerStub(self.event_loop, self.manager_address)
@ -686,8 +695,10 @@ class ProcessImpl(object):
raise
finally:
logger.info("Closing child connection...")
child_connection_handler.cleanup()
child_connection.close()
logger.info("Child connection closed.")
finally:
await self.cleanup()

@ -127,7 +127,7 @@ class EditorWindow(ui_base.CommonMixin, QtWidgets.QMainWindow):
while self._project_tabs.count() > 0:
view = self._project_tabs.widget(0)
view.close()
await view.cleanup()
self._project_tabs.removeTab(0)
self._settings_dialog.close()
self.close()
@ -443,15 +443,6 @@ class EditorWindow(ui_base.CommonMixin, QtWidgets.QMainWindow):
def closeEvent(self, event):
logger.info("CloseEvent received")
for idx in range(self._project_tabs.count()):
view = self._project_tabs.widget(idx)
closed = view.close()
if not closed:
event.ignore()
return
self._project_tabs.removeTab(idx)
event.accept()
self.app.quit()

Loading…
Cancel
Save