1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 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 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 <2021> 2022 2023 2024 |
<== Date ==> | <== Thread ==> |
---|
Subject: | Re: Incompatibility of pyepics and pvaPy 4.0.0 on Windows |
From: | Matt Newville via Tech-talk <tech-talk at aps.anl.gov> |
To: | "Johnson, Andrew N." <anj at anl.gov> |
Cc: | EPICS tech-talk <tech-talk at aps.anl.gov>, "Veseli, Sinisa" <sveseli at anl.gov>, "De Carlo, Francesco" <decarlo at anl.gov>, "Nikitin, Viktor" <vnikitin at anl.gov> |
Date: | Fri, 10 Sep 2021 10:05:47 -0500 |
It occurred to me later that the situation I was thinking about should only occur if the code was using the CA Provider through the pvaccess API, which is unlikely to be the case here, the code is using pyepics for CA channels and pvapy for PVA channels. However I do think that the access fault you’re seeing is because a thread that is calling libca doesn’t have a CA context.
On Sep 9, 2021, at 5:16 PM, Mark Rivers <rivers at cars.uchicago.edu> wrote:
Ø That could mean that calling pyepics code from inside a pvaccess callback/notification routine might no longer work if pyepics doesn’t properly set its CA context before calling routines inside libca (unfortunately that’s probably what’s happening, given the access violation that Mark is seeing).The pyepics call that it crashing is not happening inside a pvaccess callback/notification routine, it is happening in the following code:class TomoScan():…def __init__(self, pv_files, macros):…# Start the watchdog timer threadthread = threading.Thread(target=self.reset_watchdog, args=(), daemon=True)thread.start()…def reset_watchdog(self):"""Sets the watchdog timer to 5 every 3 seconds"""while True:self.epics_pvs['Watchdog'].put(5)time.sleep(3)So the tomoscan constructor is creating a new thread with threading.Thread. That thread is running the simple reset_watchdog function, which simply does an epics.PV.put(5) every 3 seconds. That call crashes with pvaccess 4.0.0 under the following conditions:- tomoscan is built with the functions that include pvaccessor- tomoscan is built without pvaccess but PYEPICS_LIBCA is pointing to the version of ca.dll that comes with pvaccess
Does pyepics give access to the libca routines ca_current_context() and ca_attach_context() ? If so I would recommend having that watchdog thread explicitly attach to the context that was created for the main thread. I think that will probably solve the problem if those APIs are available.