Hi Matt,
I will try to have our pyepics upgraded to the latest version. For now, the solution you suggested that cache be cleared up after closing a channel should work for me.
Thanks again for you help.
William
----- Original Message -----
From: "Matt Newville" <[email protected]>
To: "weiwei" <[email protected]>
Cc: "tech-talk" <[email protected]>
Sent: Tuesday, August 23, 2016 9:24:15 AM
Subject: Re: Is There A Way to Explicitly Close CA Connections in PyEpics?
Hi,
On Fri, Aug 19, 2016 at 10:50 AM, Weiwei Lu <[email protected]> wrote:
> 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?
>
You should be able to do
import epics
print(epics.__version__)
The latest version of pyepics is 3.2.6, and I'd suggest upgrading to the
latest version before trying to diagnose problems.
> 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.
Yes, that is true.
> 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.
>
The CA client library handles how often to search and connect to unresolved
PVs. It seems like it's not often a problem to have a few unresolved
PVs. But that's not to say that it is OK that you cannot fully disconnect
from PVs -- you should definitely be able to do that.
> > import gc
> > gc.collect()
>
> Calling gc.collect() after executing pv = None, the connection remained
> open. So this does not work.
>
Hm, weird. I don't know why that would be (especially given that the code
below works). Upgrading to the latest version might help.
>
> > 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.
>
>
--Matt
- References:
- Is There A Way to Explicitly Close CA Connections in PyEpics? Weiwei Lu
- Re: Is There A Way to Explicitly Close CA Connections in PyEpics? Matt Newville
- Re: Is There A Way to Explicitly Close CA Connections in PyEpics? Weiwei Lu
- Re: Is There A Way to Explicitly Close CA Connections in PyEpics? Matt Newville
- Navigate by Date:
- Prev:
Re: Is There A Way to Explicitly Close CA Connections in PyEpics? Matt Newville
- Next:
Modbus R2-9 available Mark Rivers
- 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
- Navigate by Thread:
- Prev:
Re: Is There A Way to Explicitly Close CA Connections in PyEpics? Matt Newville
- Next:
September EPICS meeting: Timing and Open FPGA HW Platform Jukka Pietarinen
- 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
|