How to unexport my Pytango device servers

Hi @aglas

Yes, there are some issues with clean shutdown. (Hopefully fixed in the upcoming 10.1.0 release, thanks to recent change in cppTango).

The most common cause is starting a thread before the device server is started. The signals to interrupt and terminate the application, SIGINT and SIGTERM, could get handled by that user thread, instead of cppTango’s signal handling thread. If that is happening, there won’t be a clean shutdown, so the device server won’t get a chance to unexport itself.

If you aren’t creating your own threads, it could be a dependency like numpy that automatically starts some background threads (depending on configuration, and the underlying linear algebra libraries it is using, e.g., libblas).

There is some discussion here: Revise treatment of SIGTERM in Linux (#927) · Issues · tango-controls / cppTango · GitLab

That thread includes a suggestion about masking signals in the Python code, before importing anything else. Adding your own signal handler or __del__ method won’t help.

Some relevant PyTango issues:

Regards,
/Anton