lava icon indicating copy to clipboard operation
lava copied to clipboard

Creating a process and never running it causes an error when the process is deleted.

Open tim-shea opened this issue 2 years ago • 0 comments

Describe the bug When I create an object that derives from AbstractProcess and never call run, it should not invoke stop during garbage collection.

To reproduce current behavior

from lava.magma.core.process.process import AbstractProcess

class ClientProcess(AbstractProcess):
    def __init__(self):
        pass

if __name__ == '__main__':
    client = ClientProcess()
  1. I get this error ...
Traceback (most recent call last):
  File "/Users/tshea/Documents/ronan/remote_loihi_poc/snippets/echo_client.py", line 37, in <module>
    client = ClientProcess()
             ^^^^^^^^^^^^^^^
  File "/Users/tshea/Documents/ronan/lava/src/lava/magma/core/process/process.py", line 33, in __call__
    getattr(obj, "_post_init")()
  File "/Users/tshea/Documents/ronan/lava/src/lava/magma/core/process/process.py", line 239, in _post_init
    attrs = self._find_attr_by_type(OutPort)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tshea/Documents/ronan/lava/src/lava/magma/core/process/process.py", line 260, in _find_attr_by_type
    attr = getattr(self, attr_name)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tshea/Documents/ronan/lava/src/lava/magma/core/process/process.py", line 445, in is_compiled
    return self._is_compiled
           ^^^^^^^^^^^^^^^^^
AttributeError: 'ClientProcess' object has no attribute '_is_compiled'. Did you mean: 'is_compiled'?
Exception ignored in: <function AbstractProcess.__del__ at 0x107d36d40>
Traceback (most recent call last):
  File "/Users/tshea/Documents/ronan/lava/src/lava/magma/core/process/process.py", line 221, in __del__
    self.stop()
  File "/Users/tshea/Documents/ronan/lava/src/lava/magma/core/process/process.py", line 414, in stop
    if self.runtime:
       ^^^^^^^^^^^^
  File "/Users/tshea/Documents/ronan/lava/src/lava/magma/core/process/process.py", line 275, in runtime
    return self._runtime
           ^^^^^^^^^^^^^
AttributeError: 'ClientProcess' object has no attribute '_runtime'

Expected behavior No error should be produced.

Environment (please complete the following information):

  • Device: Laptop
  • OS: Mac
  • Lava version 0.8

tim-shea avatar Aug 01 '23 17:08 tim-shea