EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  <20192020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  <20192020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: How to set timeout for reading a pyepics device attribute [SEC=UNOFFICIAL]
From: Matt Newville via Tech-talk <[email protected]>
To: "CORNALL, Terry" <[email protected]>
Cc: "[email protected]" <[email protected]>
Date: Tue, 3 Dec 2019 10:05:26 -0600
Hi Terry, 

On Mon, Dec 2, 2019 at 11:00 PM CORNALL, Terry via Tech-talk <[email protected]> wrote:

Hi All.

If I use pyepics devices, such as a motor, via:

m=epics.Motor('SR10BM01SPAL03:SPIN’, timeout=5)

And then try to read some attribute, like:

jvel=m.JVEL

it sometimes happens that the attempt to read the attribute times out in 1 second. (rare, but it does happen)

UserWarning: ca.get('SR10BM01SPAL03:SPIN.JVEL') timed out after 1.00 seconds.

 

The timeout=5 specified in creating the device instance above in my example appears to be a ‘connection timeout’ used when first making the device instance rather than the timeout used when getting an attribute value.

 

I’ve pondered the code and doco but can’t see how to set  the timeout that applies to reading an attribute.

If I use an epics.Motor.get() like

Jvel=m.get(‘JVEL’, timeout=5)

I get an error about unexpected keyword argument ‘timeout’, and looking at the code in epics/motor.py supports that I can’t do it that way.

 

According to code in epics/motor.py, Motor.get() uses PV.get() but doesn’t specify any timeout  so I get stuck with a hard-coded 1 second.

 

I guess I can get the epics.Motor’s PV as a string and then attach the attribute string and then use PV.get(pvstring, timeout=5) but it seems a bit hacky if there is a better way that I’ve missed.

 

Any thoughts?

Terry



You are right that the `timeout` to the underlying `PV.get()` is not exposed through the Motor `get()` method.  It probably should be, and that would be easy to fix. 

You could first lookup the PV for the specific motor attribute and use its `get()` method, perhaps like

   m = epics.Motor('SR10BM01SPAL03:SPIN’,  
   jog_speed = m.PV('JVEL').get(timeout=10.0)

That would require knowing how the Motor Devices'  PVs are indexed which is by "field suffix" ('VAL', 'JVAL', 'HOPR', and so forth), so that whereas you could get 
that jog speed using
  
  jog_speed = m.get('jog_speed') 

you could not do
  
  jog_speed = m.PV('jog_speed').get()  # Nope, have to use 'JVEL'


Note also that there is sort of a double use for the `timeout` argument in `PV.get()`.  First, it is used as a connection timeout if the PV is not already connected.   Then it is used as the timeout to get the actual data.  That means that if the PV really is not connected, `PV.get(timeout=5.0)` really will return after 5+delta seconds (delta ~1ms).  If the PV is very slow to connect and fetch the data, it could take longer than 5 seconds.  I don't think I've ever seen that situation, but it is possible. 

I'll put "expose get() timeout to Devices and Motors" on the to-do list.

--Matt 


References:
How to set timeout for reading a pyepics device attribute [SEC=UNOFFICIAL] CORNALL, Terry via Tech-talk

Navigate by Date:
Prev: Re: MySQL statement in caMonitor code Aaron Brown via Tech-talk
Next: RE: MySQL statement in caMonitor code Mark Rivers via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  <20192020  2021  2022  2023  2024 
Navigate by Thread:
Prev: How to set timeout for reading a pyepics device attribute [SEC=UNOFFICIAL] CORNALL, Terry via Tech-talk
Next: Phoebus and Archiver Appliance Rory Clarke - UKRI STFC via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  <20192020  2021  2022  2023  2024 
ANJ, 03 Dec 2019 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·