descrease PyTango.DeviceProxy() creation time

Hi all,

We are trying to create device proxies of multiple device servers using PyTango API.
dp = PyTango.DeviceProxy('some/tango/device')

But this takes approx 3 seconds to create one device proxy. It takes almost 1 minutes to create all device proxies.

Can this time be reduced? or is there any other way to avoid this problem?

Regards,
tgmrt
Regards,
TCS_GMRT
Hi,
very strange. When I create a DeviceProxy on my laptop it takes 100ms. I used this code to measure it:
#!/usr/bin/python
import timeit
s="""\
import PyTango
dp=PyTango.DeviceProxy("sys/tg_test/1")
"""
print "Device proxy took : ",timeit.timeit(stmt=s, number=1)*1000," ms"
The output is
Device proxy took :  131.583929062  ms
If your DeviceProxy takes 3 seconds there is a problem with your setup. How long does it take to ping the host where the device is on? 3 seconds is the default timeout with Tango. Maybe your DeviceProxy is timing out and not really connecting to the device. Have you tried to ping the device with the Test device application in jive? How long does it take?

Andy
Hi Andy,
Just one comment concerning the benchmark: I think your test is a little bit unfair to Tango smile
You include in benchmark the time to import PyTango.
Changing it a bit gives more interesting numbers:


import timeit
number = 1000
t = timeit.timeit('dp=PyTango.DeviceProxy("sys/tg_test/1")', 'import PyTango', number=number)
print('{0} calls took {1} ({2} ms/call)'.format(number, t, t/number*1000.))

…which on my computer gives around 0.8 ms.

Hi all,
Thank you Andy and TCoutinho for reply,
As Andy said
there is a problem with your setup,
Particularly with network setup problems, remote host is not available on the local network.
Because of which following errors can be also be seen,

PyTango.ConnectionFailed: DevFailed[
DevError[
desc = TRANSIENT CORBA system exception: TRANSIENT_ConnectFailed
origin = Connection::connect
reason = API_CorbaException
severity = ERR]

DevError[
desc = Failed to connect to database on host <hostname> with port 10000
origin = Connection::connect
reason = API_CantConnectToDatabase
severity = ERR]
Clearly it can also be noted that time is taken equivalent to default timeout period.

So we need to check if particular host is available or not in multiple-host environment before trying for device proxy.
Any suggestions about how to check it in tango way?

Regards,
tgmrt
Regards,
TCS_GMRT
TCoutinho
…which on my computer gives around 0.8 ms.
You are right. On my computer it took .43 ms/call. Not bad when you think it does a call to the database and device server …

Andy
TCS_GMRT,
you can check the host is available with a ping or telnet. I don't know if we can reduce the timeout at the import time from 3s to a few ms. I have to ask the experts. Then you could do a dev_ping(). This way you know if the device server and database are available.
Cheers
Andy
Hi Andy,

Thanks for your suggestion,
You can check the host is available with a ping or telnet
We are using python's system calls to ping to the host before trying for device proxies. And the time is reduced to some extent.

About
I don't know if we can reduce the timeout at the import time from 3s to a few ms. I have to ask the experts.
Did you get any chance to talk with experts and what are their suggestion on this?


Thanks and Regards,
TCS_GMRT
Regards,
TCS_GMRT
 
Register or login to create to post a reply.