Crash when throwing an exception from delete_device

The following pytango example crashes due to an uncaught C++ exception during device server shutdown (using a pytango wheel built with main):

#!/usr/bin/env python

from tango.server import Device

from tango.test_context import DeviceTestContext

class MyDevice(Device):
    def delete_device(self):
        raise RuntimeError("Don't crash please")

if __name__ == '__main__':
    with DeviceTestContext(MyDevice) as dp:
        dp.ping()

I think this is a bug in the user code, the delete_device() method should not raise an exception. However, I don't think we should crash here and instead handle this a little more gracefully.

As per https://gitlab.com/tango-controls/cppTango/-/blob/main/src/include/tango/server/device.h?ref_type=heads#L450, cppTango allows subclasses to throw from delete_device(), so we should handle any exceptions during shut down. I guess we should log an error and then continue.

Edited Jul 21, 2025 by Thomas Ives
Assignee Loading
Time tracking Loading