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: catching python exception in pcaspy
From: Jameson Graef Rollins <jrollins@ligo.caltech.edu>
To: Tech Talk <tech-talk@aps.anl.gov>
Date: Sun, 07 Jul 2013 12:42:14 -0700
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)

Attachment: pgpvGv0QOXWOK.pgp
Description: PGP signature


Replies:
Re: catching python exception in pcaspy Xiaoqiang Wang

Navigate by Date:
Prev: Re: asyn+streamDevice hangs with synchronousLock:Yes Brian McAllister
Next: Re: catching python exception in pcaspy Xiaoqiang Wang
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: Re: Development with EPICS and CSS marcus . michalsky
Next: Re: catching python exception in pcaspy Xiaoqiang Wang
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 ·