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

Subject: Re: pyepics problem with PV.put(wait=True)
From: Matt Newville <[email protected]>
To: Jameson Graef Rollins <[email protected]>
Cc: EPICS tech-talk <[email protected]>
Date: Fri, 15 Aug 2014 07:42:19 -0500
Hi Jameson,


On Fri, Aug 15, 2014 at 12:52 AM, Jameson Graef Rollins <[email protected]> wrote:
On Thu, Aug 14 2014, Matt Newville <[email protected]> wrote:
> Sorry for the trouble.  The basic issue here is that PV.get() relies (by
> default) on a callback on the monitored value to keep the PV's value
> up-to-date, avoiding explicit calls to ca.get().    The put(wait=True) or
> put-with-callback uses a *different* callback on the put() request.    When
> the put-callback completes, the callback for the monitored value may not
> have been run.

Hey, Matt (and Mark).  Thank you both so much for the speedy responses.
I suspected I was seeing the race condition that you both describe.

> It's reasonable to say that when the put-with-wait completes that the
> cached value  should be updated.  I'll look into that.

Yeah, if that was possible I think that might best jive with
expectations.  Thanks for looking into it.

> The alternative is to:
>     for i in range(10):
>         pv.put(i, wait=True)
>         print pv.get(auto_monitor=False)
>
> which will make an explicit call to ca.get() every time, not relying on the
> monitored value.   That will add a potential delay, but is probably the
> safest way to ensure that the value is the current one.

I think this is probably the solution I'm looking for, although I need
to ponder whether or not the overhead of a full get() is worth it.
Seems like just reporting the newly written value is sufficient for our
purposes.

If you're really just doing a loop like the above example, and already waiting for the put() to complete, the small extra time to wait for the "real, explicit" ca_get() to run is probably insignificant.   If that was just a test to show the inconsistency, then, yeah it depends on how soon you need the value.

It's probably reasonable to have  PV.get() do an explicit ca.get() by default -- have use_monitor=False as the default --  and use the "value" attribute to hold "the most recent value posted by monitor" without doing an explicit ca.get().   I don't think that would really break much code. It might cause other confusion, but probably less than the current state.  I'd happily listen to advice on "the right behavior" for this, but probably want to wait for a new minor version to make this change.

Like Tim said, the PV() class does not expose supplying a callback to get() and then waiting for that to have run before updating the fetched value.    That might be worth having too.
 
--Matt Newville

References:
pyepics problem with PV.put(wait=True) Jameson Graef Rollins
Re: pyepics problem with PV.put(wait=True) Matt Newville
Re: pyepics problem with PV.put(wait=True) Jameson Graef Rollins

Navigate by Date:
Prev: RE: Problem with creating an array of Long with aSub record michael.abbott
Next: RE: Problem with creating an array of Long with aSub record Mark Rivers
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  <20142015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: pyepics problem with PV.put(wait=True) Jameson Graef Rollins
Next: Web OPI Xinyu.Wu
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  <20142015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 17 Dec 2015 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·