ThatsTheEnd / horiba-python-sdk

MIT License
3 stars 3 forks source link

refactor ccd for better context manager usage #40

Closed w-samuelgauthier closed 4 months ago

w-samuelgauthier commented 4 months ago

Changelog: changed

Description

Refactor ChargeCoupledDevice, AbstractCommunicator, WebsocketCommunicator, DeviceManager to allow better context manager usage.

Related Issue

39

Type of Change

Checklist

w-samuelgauthier commented 4 months ago

The cause of the failing unit tests with the HW, is due to the fact that DeviceManager is a singleton running its own event loop. The solution is to either:

ThatsTheEnd commented 4 months ago

The cause of the failing unit tests with the HW, is due to the fact that DeviceManager is a singleton running its own event loop. The solution is to either:

  • Remove the singleton annotation on DeviceManager and just make it non-singleton, the event loop from conftest.py can then be used
  • Pass the event loop through the constructor of the DeviceManager

Hi Samuel, you genius, that you found out this fact. I don't particularly like to mess around with handling loops. I think this should be handled by the programming language itself. So my first attempt would be to remove the singleton annotation from the device handler. Kudos that you found the source of this behaviour!