Skip to content
This repository has been archived by the owner on Mar 17, 2021. It is now read-only.

Import taurus in PyTango DS causes that delete_device is not called at shutdown #982

Open
reszelaz opened this issue Jul 30, 2019 · 4 comments
Labels

Comments

@reszelaz
Copy link

Not sure if this is a problem in Taurus or PyTango. But if I import taurus in PyTango DS this causes that the delete_device method is not called at the DS shutdown. This does not happen with python 2 but happens with python 3.

To reproduce:

  1. Copy the following snippet in PyDsExp.py file:
import sys

import PyTango
import taurus


class PyDsExpClass(PyTango.DeviceClass):


    def __init__(self, name):
        PyTango.DeviceClass.__init__(self, name)
        self.set_type("TestDevice")


class PyDsExp(PyTango.Device_4Impl):

    def __init__(self,cl,name):
        PyTango.Device_4Impl.__init__(self, cl, name)
        PyDsExp.init_device(self)

    def init_device(self):
        self.set_state(PyTango.DevState.ON)

    def delete_device(self):
        print("delete_device")


if __name__ == '__main__':
    util = PyTango.Util(sys.argv)
    util.add_class(PyDsExpClass, PyDsExp)

    U = PyTango.Util.instance()
    U.server_init()
    U.server_run()
  1. Define PyDsExp DS instance with one device:
tango_admin --add-server PyDsExp/test PyDsExp test/pydsexp/1

On Debian tango_admin is installed in /usr/lib/tango.

  1. Run DS:
python3 PyDsExp.py test
  1. After the DS is ready press Ctrl + C.

Then, you won't observe "delete_device" print. When you run it with python 2 you can see it.

@cmft
Copy link
Member

cmft commented Aug 5, 2019

The problem is caused by:

from pint import UnitRegistry
UR = UnitRegistry()

in taurus.core.units module

@cmft
Copy link
Member

cmft commented Aug 5, 2019

The problem can be simplified importing just pint

@mrosanes
Copy link
Collaborator

mrosanes commented Aug 5, 2019

I don't know why, but in my machine debain9 I cannot reproduce the problem with python3 and PyTango version 9.2.5. The print 'delete_device' appears correctly.

However in python2 and PyTango version 9.2.0 the print is not there; the delete_device method is not called in python2 in my case.

@cpascual cpascual added the bug label Aug 19, 2019
@cmft
Copy link
Member

cmft commented Aug 30, 2019

Now, I reproduce the problem in my stretch machine with both Py2 and Py3.
I can not reproduce the error with the taurus Py3 conda env. (using tango 9.3.1)

Pint is 0.9 version in all case.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants