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  <20162017  2018  2019  2020  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  <20162017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: PyEpics timeout behavior
From: Matt Newville <[email protected]>
To: "Guyotte, Greg S." <[email protected]>
Cc: "[email protected]" <[email protected]>
Date: Tue, 30 Aug 2016 10:47:58 -0500
Hi Greg,

Sorry for the trouble and confusion.

On Tue, Aug 30, 2016 at 9:43 AM, Guyotte, Greg S. <[email protected]> wrote:
I’m experiencing unexpected timeout behavior on PyEpics 3.2.4.

Using epics.PV, I experience double the expected timeout in all cases.

Yes, I see that too. It looks to me like you've exposed 2 separate flaws in the code for PV timeouts.
 
Using epics.caget(), the timeout value seems to be ignored and I
experience 5 seconds of delay when I ask for less than 5 seconds.  With
epics.caget(), if I ask for more than 5 seconds of timeout, it works as
expected.

Here is a simple Python test case to reproduce:

  import epics, time

  waittime = 2
  print "PyEpics %s test with timeout of %d seconds" %
(epics.__version__,waittime)

  print "Test 1: using epics.PV"
  time1 = time.time()
  p = epics.PV("idontexist", connection_timeout=waittime)
  time2 = time.time()
  print "  Time to create non-existent PV= ",time2-time1
  val = p.get(timeout=waittime, use_monitor=False)
  time3 = time.time()
  print "  Time to get non-existent PV= ",time3-time2



There are meant to be 2 different wait times: a timeout for connecting to a PV, and a timeout for getting a value.

When you do  (I'm deliberately using different and non-default timeout values here):
    p = epics.PV('idontexist', connection_time=2.5)

this does not actually wait for the connection to happen, but does set the connection timeout.   Later, when you try to get the value with
    val = p.get(timeout=1.5)

it will notice that the PV is not connected and try to connect (calling `p.wait_for_connection()`).    This should wait up to 2.5 seconds.  In fact, it's currently effectively doing that twice the first time, so waiting 5.0 seconds -- this is what you see, and the code should be fixed to not wait twice. 

But, because the PV here never connects, the timeout for getting the value is (and should be) irrelevant.

 
  print ""

  print "Test 2: using epics.caget"
  time1 = time.time()
  val = epics.caget("idontexist", timeout=waittime, use_monitor=False)
  time2 = time.time()
  print "  Time to caget non-existent PV= ", time2-time1


The situation with `epics.caget()` is somewhat different.  Here, the `timeout` value is used as the timeout for getting a value from a connected PV, and the connection timeout (this time, not doubled!) is currently set to 5.0 seconds, without an option to change that value.

Both of these should be simple to fix:
    A) do not wait 2*connection_wait_time for the initial connection
    B) use `timeout` in `epics.caget()` as the timeout for the entire operation (connection + get).

I'll push these changes to the master branch soon.

--Matt
 

Replies:
Re: PyEpics timeout behavior Guyotte, Greg S.
References:
PyEpics timeout behavior Guyotte, Greg S.

Navigate by Date:
Prev: Re: [UNTRUSTED] PyEpics timeout behavior Kasemir, Kay
Next: Re: PyEpics timeout behavior Guyotte, Greg S.
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: [UNTRUSTED] PyEpics timeout behavior Kasemir, Kay
Next: Re: PyEpics timeout behavior Guyotte, Greg S.
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 30 Aug 2016 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·