Skip to content

Fix DeviceProxy constructor reference cycle

Anton Joubert requested to merge issue-412 into develop

This problem is fixed in two ways:

  • ensure the cause object that holds the exception with a reference cycle is cleared in the DeviceProxy__set_attr method. Similarly, clearing done in __DeviceProxy__getattr for symmetry.
  • Prevent the exception in the first place, by bypassing the calls to __setattr while constructing the DeviceProxy object.
    The __setattr method tries to read the commands and attributes from the device, but this isn't possible so early in the constructor.

Added a test to cover this case. Both the new test, and the existing memory leak tests for DeviceProxy were made a little more lenient as we see occasional failures in the pipeline. The causes could not be pinned down.

Change the bare except: statement in __DeviceProxy___get_info_ to the general except Exception:. This in line with PEP8. The method is only used for str() and repr(), so it shouldn't need to catch SystemExit and KeyboardInterrupt.

Closes #412 (closed)

Merge request reports