Ulm-IQO / qudi-core

A framework for modular measurement applications.
GNU General Public License v3.0
38 stars 21 forks source link

[Bug] remote modules do not deactivate cleanly #57

Closed qku closed 1 month ago

qku commented 1 year ago

Version

Release v1.4.1

What is affected by the bug?

When deactivating a remote module on the client qudi instance, an exception is raised. After this, qudi cannot be quit normally anymore but only terminated from e.g. the console.

When does the bug occur?

Every time when trying to deactivating a remote module on the client qudi instance.

How do we replicate the issue?

can be replicated with e.g. data instream dummy or time series reader logic from iqo-modules

Expected behavior

qudi should not raise an error and shut down properly when requested to.

Relevant log output

Traceback (most recent call last):
  File "C:\Software\qudi\qudi-env\lib\site-packages\qudi\core\modulemanager.py", line 601, in deactivate       
    self.__poll_timer.stop()
AttributeError: 'NoneType' object has no attribute 'stop'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Software\qudi\qudi-env\lib\site-packages\qudi\core\modulemanager.py", line 208, in deactivate_module
    self._modules[module_name].deactivate()
  File "C:\Software\qudi\qudi-env\lib\site-packages\qudi\core\modulemanager.py", line 604, in deactivate       
    self._instance.module_state.sigStateChanged.disconnect(self._state_change_callback)
  File "C:\Software\qudi\qudi-env\lib\site-packages\rpyc\core\netref.py", line 240, in __call__
    return syncreq(_self, consts.HANDLE_CALL, args, kwargs)
  File "C:\Software\qudi\qudi-env\lib\site-packages\rpyc\core\netref.py", line 63, in syncreq
    return conn.sync_request(handler, proxy, *args)
  File "C:\Software\qudi\qudi-env\lib\site-packages\rpyc\core\protocol.py", line 718, in sync_request
    return _async_res.value
  File "C:\Software\qudi\qudi-env\lib\site-packages\rpyc\core\async_.py", line 108, in value
    raise self._obj
_get_exception_class.<locals>.Derived: Failed to disconnect signal sigStateChanged(PyObject).

========= Remote Traceback (1) =========
Traceback (most recent call last):
  File "C:\Software\qudi\qudi-env\lib\site-packages\rpyc\core\protocol.py", line 359, in _dispatch_request
    res = self._HANDLERS[handler](self, *args)
  File "C:\Software\qudi\qudi-env\lib\site-packages\rpyc\core\protocol.py", line 837, in _handle_call
    return obj(*args, **dict(kwargs))
RuntimeError: Failed to disconnect signal sigStateChanged(PyObject).

Additional Comments

No response

Contact Details

No response

qku commented 1 month ago

The issue only occurs if the module on the server is already active when the client connects to it. Then, the activate method of the managed module returns early to skip actual module activation:

https://github.com/Ulm-IQO/qudi-core/blob/2dd3a4553524e0058c19a2859034e6115e15de21/src/qudi/core/modulemanager.py#L510-L515

However, the creation of the poll timer is then also skipped:

https://github.com/Ulm-IQO/qudi-core/blob/2dd3a4553524e0058c19a2859034e6115e15de21/src/qudi/core/modulemanager.py#L573-L580

Deactivation of the module from the client therefore fails, since neither a poll timer was created nor sigStateChanged was connected.