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: Luca Luisa <[email protected]>
To: Jeff Hill <[email protected]>
Cc: "'EPICS Tech Talk'" <[email protected]>
Date: Wed, 20 Apr 2011 09:21:45 +0200
Hi,
I tried to types of code:

1. in the first one I don't disconnect the PV when the Server disconnects and I just wait an automatic reconnection. 2. in the second I disconnect the PV, and re-create it again when the server connects again.

In both cases I get the same error.

Luca



On 04/19/2011 12:19 AM, Jeff Hill wrote:
Hi Matt, Luca,

Sorry about the delay responding - I was away on business at the end of last
week.

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)
-----------------------------------------------------------------------


Despite some similarities, I don’t believe that this particular message
originates from the ca client library.

Note also that if you do not unsubscribe when the circuit becomes
unresponsive then the ca client library will auto-magically re-subscribe on
your behalf should the channel need to be reconnected on a fresh TCP
circuit.

Jeff
______________________________________________________
Jeffrey O. Hill           Email        [email protected]
LANL MS H820              Voice        505 665 1831
Los Alamos NM 87545 USA   FAX          505 665 5107

Message content: TSPA

With sufficient thrust, pigs fly just fine. However, this is
not necessarily a good idea. It is hard to be sure where they
are going to land, and it could be dangerous sitting under them
as they fly overhead. -- RFC 1925

-----Original Message-----
From: [email protected] [mailto:tech-talk-
[email protected]] On Behalf Of Matt Newville
Sent: Thursday, April 14, 2011 10:07 AM
To: [email protected]; EPICS Tech Talk
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


Replies:
Re: ca.py - Throws error - workaround Matt Newville
Re: ca.py - Throws error - workaround Geoff Savage
References:
Re: ca.py - Throws error - workaround Matt Newville
RE: ca.py - Throws error - workaround Jeff Hill

Navigate by Date:
Prev: emacs modes for EPICS? Angus Gratton
Next: Handling of Array in CaChannel library Ritesh Sugandhi
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 Matt Newville
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 ·