On 5/3/19 1:58 PM, Matt Newville via Tech-talk wrote:
> I do not know of a way to ask "what dynamic libs are already loaded" from python
You can check if the process already include symbols ca_context_create.
> hasattr(cdll.LoadLibrary(None), 'ca_context_create')
OK, thanks -- that might be useful. To be clear, this returns False for me in the "normal" case of actually loading `libca` for the first time from a Python session:
>>> from ctypes import cdll
>>> from
epics.ca import find_libca
>>> dllname = find_libca()
>>> print(dllname)
/Users/Newville/anaconda3/lib/python3.7/site-packages/epics/clibs/darwin64/libca.dylib
>>> libca = cdll.LoadLibrary(dllname)
>>> print(hasattr(libca, 'ca_context_create'),
hasattr(cdll.LoadLibrary(None), 'ca_context_create'))
True False
So that might be a reliable way to answer the question "am I running as an embedded Python within an IOC-like process that has loaded libca?". That would be good to know. Registering epicsAtExit() might be useful in all cases, but it seems like we might really need to do that when embedded in an IOC.
--Matt