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

Subject: Re: ca.py - Throws error - workaround
From: Tim Mooney <[email protected]>
To: Matt Newville <[email protected]>
Cc: luca luisa <[email protected]>, EPICS Tech Talk <[email protected]>
Date: Thu, 14 Apr 2011 13:09:37 -0500 (CDT)
I think there's no point in calling clear_callbacks() when you notice that
a server has disconnected.  If this function does what I think it does (calls
ca_clear_subscription()), then, in addition to unregistering a function, it's
trying to send a message to a server that you think is disconnected (telling
it to stop sending you monitor events).

If there happen to be outstanding monitors when ca_clear_subscription() is called,
then channel access will be in the awkward position of having a value-change monitor
you told it to notify you about, but having no callback function registered to
accept the notification.  Maybe it's falling back to calling whatever callback
function does exist, rather than simply discarding the monitor.

Tim Mooney

----- Original Message -----
> From: "Matt Newville" <[email protected]>
> To: "luca luisa" <[email protected]>, "EPICS Tech Talk" <[email protected]>
> Sent: Thursday, April 14, 2011 11:07:11 AM
> Subject: Re: ca.py - Throws error - workaround
> Hi Luca,
> 
> I hope it's OK with you that I'm sending the message to Tech-Talk,
> where there are many people with much better understanding of Channel
> Access than I have.
> 
> On Thu, Apr 14, 2011 at 1:58 AM, Luca Luisa <[email protected]>
> wrote:
> > Hi,
> > I'm working with PyEpics version 3.1.1.
> > My QT Python application communicates with many EPICS servers where
> > hundred
> > of PVs are delivered.
> >
> > Our application has to deal with any EPICS server
> > disconnection/re-connection that can happen during the application
> > run.
> >
> > Each PV used by this QT Python application has a callback function
> > added
> > with the module "add_callback()".
> >
> > When I noticed an EPICS server disconnection, I clear the callbacks
> > with the
> > method "clear_callbacks()".
> >
> > When any EPICS server re-connect again, I try to add again another
> > callback
> > function to the same PV instance previously created, if fails (the
> > add_callback returns None) I re-create the PV instance again and try
> > to add
> > the callback function.
> >
> > But in the cycle above described used to handle the dynamic
> > connection to
> > EPICS server, I get a lot of unknown errors in the terminal from
> > where I
> > launch my application, those are:
> >
> > -------------------------------------------------------------------------------
> > TypeError: __on_connect() got an unexpected keyword argument 'count'
> > Traceback (most recent call last):
> >  File "_ctypes/callbacks.c", line 295, in 'calling callback
> >  function'
> >  File "/usr/local/lib/python2.6/dist-packages/epics/ca.py", line
> >  420, in
> > _onGetEvent
> >    args.usr(value=value, **kwds)
> > -------------------------------------------------------------------------------
> >
> > Our application is very complex so I cannot send you an example.
> >
> > In order to remove this error that full-fills the terminal window, I
> > had to
> > change the "ca.py" source with a try: except: statement.
> > The diff is:
> >
> > 419,423c419,420
> > < try:
> > < if hasattr(args.usr, '__call__'):
> > < args.usr(value=value, **kwds)
> > < except:
> > < """"""
> > ---
> > >     if hasattr(args.usr, '__call__'):
> > >         args.usr(value=value, **kwds)
> >
> > My solution is a pure workaround to make my application working and
> > I got
> > success but I would like to know if this is a known error or my way
> > to
> > handle connection/disconnection of a EPICS server is wrong.
> >
> > Many thanks
> >
> > Ing. Luca Luisa
> 
> I'm reluctant to make that change, as it's the only place ca.py can
> tell the programmer that there was an error in running the
> user-supplied callback and this change silences that message.
> 
> This message:
> 
> > TypeError: __on_connect() got an unexpected keyword argument 'count'
> > Traceback (most recent call last):
> >  File "_ctypes/callbacks.c", line 295, in 'calling callback
> >  function'
> >  File "/usr/local/lib/python2.6/dist-packages/epics/ca.py", line
> >  420, in
> > _onGetEvent
> >    args.usr(value=value, **kwds)
> 
> says that PV.__on_connect() -- the internally defined connection
> callback for a PV -- is being run as a change-in-value callback. I'm
> not sure how that's even possible.
> 
> > When I noticed an EPICS server disconnection, I clear the callbacks
> > with the
> > method "clear_callbacks()".
> 
> I'm not sure this is necessary. Have you tried not doing this?
> Obviously, you won't get a callback from a disconnected PV, and will
> get a callback upon reconnection, but I would think that's not worse
> than explicitly clearing and re-setting callbacks. I can verify that
> it does works for me in simple test scripts to not clear "change
> value" callbacks and restart the server IOC.
> 
> > When any EPICS server re-connect again, I try to add again another
> > callback
> > function to the same PV instance previously created, if fails (the
> > add_callback returns None) I re-create the PV instance again and try
> > to add
> > the callback function.
> 
> For PV.add_callback() to return None, the PV has to be unconnected --
> or at least that's the intention. So it's hard to understand what's
> happening if you wait for reconnection to add a callback. I do think
> it shouldn't be necessary to re-create the PV.
> 
> I'm not sure whether this is related to using QT. A minimal example
> would be really helpful.
> 
> --Matt

-- 
Tim Mooney ([email protected]) (630)252-5417
Software Services Group (www.aps.anl.gov)
Advanced Photon Source, Argonne National Lab



References:
Re: ca.py - Throws error - workaround Matt Newville

Navigate by Date:
Prev: Re: ca.py - Throws error - workaround Matt Newville
Next: how to write string to waveform record using a scalcout record? Jay Steele
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  <20112012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: ca.py - Throws error - workaround Matt Newville
Next: RE: ca.py - Throws error - workaround Jeff Hill
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  <20112012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 18 Nov 2013 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·