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  <20132014  2015  2016  2017  2018  2019  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019 
<== Date ==> <== Thread ==>

Subject: Re: catching python exception in pcaspy
From: Xiaoqiang Wang <xiaoqiang.wang@psi.ch>
To: Jameson Graef Rollins <jrollins@ligo.caltech.edu>
Cc: Tech Talk <tech-talk@aps.anl.gov>
Date: Sun, 7 Jul 2013 23:02:53 +0200
I have the same headache when debugging pcas applications. 
The server tool library does not provides an exception handler, like in the CA client library, this error could only be checked from the console. Even though, the error seems ambiguous and can not be directly related to the python code. 

So I normally separate functions into its own module/class/function and test them. 
And then interface to it by subclassing pcaspy Driver.

Best
Xiaoqiang

On Jul 7, 2013, at 9:42 PM, Jameson Graef Rollins <jrollins@ligo.caltech.edu> wrote:

> Hi, folks.  I'm wondering if it's possible to catch python exceptions in
> the pcaspy Driver class.  For instance, I have a very simple dummy
> server (attached), in whose write() method there is a call that should
> throw a NameError.  However, when the server is running, a CA write
> (e.g. "caput MTEST:RAND 3") produces the following output:
> 
> filename="../../../../src/cas/generic/st/casStreamOS.cc" line number=479
> Internal failure - unexpected problem with client's input - forcing disconnect
> 
> The server process also continues to run.
> 
> Is there a way to get a proper python exception out of this situation?
> I would prefer the server to terminate with the exception, but I would
> be ok with the server continuing to run if the exception in the Driver
> could at least be reported to stderr or the like.  As is it's a little
> tricky to debug these errors.
> 
> Thanks in advance for any help.
> 
> jamie.
> 
> #!/usr/bin/env python
> 
> From pcaspy import Driver, SimpleServer
> 
> prefix = 'MTEST:'
> pvdb = {
>    'RAND' : {
>        'prec' : 3,
>    },
> }
> 
> class myDriver(Driver):
>    def  __init__(self):
>        super(myDriver, self).__init__()
> 
>    def write(self, channel, value):
>        foo        
> 
> if __name__ == '__main__':
>    server = SimpleServer()
>    server.createPV(prefix, pvdb)
>    driver = myDriver()
>    while True:
>        server.process(0.1)



Replies:
Re: catching python exception in pcaspy Jameson Graef Rollins
References:
catching python exception in pcaspy Jameson Graef Rollins

Navigate by Date:
Prev: catching python exception in pcaspy Jameson Graef Rollins
Next: RE: asyn+streamDevice hangs with synchronousLock:Yes Mark Rivers
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019 
Navigate by Thread:
Prev: catching python exception in pcaspy Jameson Graef Rollins
Next: Re: catching python exception in pcaspy Jameson Graef Rollins
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019 
ANJ, 20 Apr 2015 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·