lava-nc / lava

A Software Framework for Neuromorphic Computing
https://lava-nc.org
Other
535 stars 136 forks source link

Process.stop and Runtime.stop should clean up all SystemProcesses even if they were never started. #716

Open tim-shea opened 1 year ago

tim-shea commented 1 year ago

Describe the bug When creating a process and calling process.create_runtime, that process will leak (i.e. leave open) channels and SystemProcesses on deletion if its run method is never called. If there is an exception or other problem during initialization, this could lead to inappropriate retention of system resources.

To reproduce current behavior Create a process, call process.create_runtime(), call process.stop() or delete the process to trigger release of resources. Note that the spawned actors will not be joined and the channels will not be closed.

Expected behavior Process.stop and runtime.stop should work correctly regardless of whether a process has ever been run. These methods should not rely on flags (_is_running, _is_initialized, etc) which are potentially incorrect to decide whether to clean up system resources, and should execute an exception-safe, comprehensive shutdown process whenever being deleted or stopped by the user.