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: Is There A Way to Explicitly Close CA Connections in PyEpics? |
From: | Matt Newville <[email protected]> |
To: | Weiwei Lu <[email protected]> |
Cc: | tech-talk <[email protected]> |
Date: | Tue, 23 Aug 2016 08:24:15 -0500 |
Hi Matt,
Many thanks for the suggestions.
> What version of pyepics are you using?
I think I am using pyepics-3.2.1, but not 100% sure. Is there a command that can tell which version I am using?
> Why do you want to do this?
Well, just wanted to make the program more ioc friendly. Closing the unused connections releases the resources (file descriptors, memory) of the iocs. My program is a daemon program. If it does not close the connections it has opened and are no longer needed, those connections will remain open forever.
Also how about the unresolved pv searches; will my program keeps searching those unresolved pvs forever if it does not close them explicitly? So I think by closing the unused or unresolved pvs, these problems can be avoided.
> import gc
> gc.collect()
Calling gc.collect() after executing pv = None, the connection remained open. So this does not work.
> epics.ca.clear_channel(chid)
> ctx =epics.ca.current_context()
> epics.ca._cache[ctx].pop(pvname) Yes, this works! This clears the connection and also allows re-creation of a channel on the same pv.