slaclab / meme

Wrapper for MEME services at SLAC.
0 stars 2 forks source link

AttributeError after getting PVs #7

Open finnoshea opened 1 year ago

finnoshea commented 1 year ago

When I run this script:

import meme
from datetime import datetime

pvs = [
    'CATH:IN20:111:QE',  # cathode QE
    'CAMR:IN20:186:ZERNIKE_COEFF',  # Zernike coefficients from VCC camera
    'VCTD:IN20:186:VCC_POS_X',  # X position in the VCC image
    'VCTD:IN20:186:VCC_POS_Y',  # Y position in the VCC image
    'TORO:IN20:215:TMIT1H',  # charge measured at toroid right after gun
    'LASR:IN20:196:PWR1H',  # laser energy, despite saying power
    'LASR:IN20:160:C1_H_REF',  # laser hor. centroid location on VCC - reference
    'LASR:IN20:160:C1_H_ERR',  # laser centroid location on VCC - error from ref
    'LASR:IN20:160:C1_V_REF',  # laser ver. centroid location on VCC - reference
    'LASR:IN20:160:C1_V_ERR',  # laser centroid location on VCC - error from ref
]

n_seconds = 1
from_time = datetime(2023, 10, 24, 12)
to_time = datetime(2023, 10, 24, 13, 0, n_seconds - 1 + 1)

print('testing data fetching...')
for pv in pvs:
    print('trying {:s}'.format(pv))
    t = meme.archive.get(pv, from_time=from_time, to_time=to_time, timeout=10)
    print('# values:', len(t['values']))

I get an error after all the PVs have been fetched:

AttributeError: '_ClientProvider' object has no attribute 'close' Exception ignored in: 'p4p._p4p.ClientProvider.dealloc' AttributeError: '_ClientProvider' object has no attribute 'close' AttributeError: '_ClientProvider' object has no attribute 'close' Exception ignored in: 'p4p._p4p.ClientProvider.dealloc' AttributeError: '_ClientProvider' object has no attribute 'close' AttributeError: '_ClientProvider' object has no attribute 'close' Exception ignored in: 'p4p._p4p.ClientProvider.dealloc' AttributeError: '_ClientProvider' object has no attribute 'close'

This looks like a problem with p4p, but maybe there is something meme can do to close this more gently.

finnoshea commented 1 year ago

Actually, this appears to happen when python closes.

mattgibbs commented 1 year ago

I've seen this before too! It is hard for me to reproduce, though. When I run your exact code right now, I don't get the errors (upon closing, or otherwise).

Can you give me some details of the environment you're using? Give me the output of which python.

finnoshea commented 1 year ago

which python returns nothing. I'm running inside a singularity container on SDF. Here is what I get from pip freeze:

aiosignal==1.3.1 argon2-cffi==21.3.0 argon2-cffi-bindings==21.2.0 arrow==1.2.3 asttokens==2.2.1 attrs==23.1.0 backcall==0.2.0 beautifulsoup4==4.12.2 bleach==6.0.0 blinker==1.6.2 bokeh==2.4.3 certifi==2023.5.7 cffi==1.15.1 cftime==1.6.2 charset-normalizer==3.1.0 click==8.1.3 cloudpickle==2.2.1 cmake==3.26.4 colorcet==3.0.1 comm==0.1.3 contourpy==1.0.7 cycler==0.11.0 dash==2.9.3 dash-core-components==2.0.0 dash-html-components==2.0.0 dash-table==5.0.0 dask==2023.4.1 datashader==0.14.4 datashape==0.5.2 debugpy==1.6.7 decorator==5.1.1 defusedxml==0.7.1 epicscorelibs==7.0.7.99.0.0 executing==1.2.0 fastjsonschema==2.16.3 ffmpeg==1.4 filelock==3.12.0 Flask==2.3.2 fonttools==4.39.4 fqdn==1.5.1 frozenlist==1.3.3 fsspec==2023.4.0 grpcio==1.51.3 h5py==3.8.0 holoviews==1.15.4 idna==3.4 imageio==2.28.1 importlib-metadata==6.6.0 ipykernel==6.22.0 ipython==8.13.2 ipython-genutils==0.2.0 isoduration==20.11.0 itsdangerous==2.1.2 jedi==0.18.2 Jinja2==3.1.2 joblib==1.2.0 jsonpointer==2.3 jsonschema==4.17.3 jupyter-events==0.6.3 jupyter_client==8.2.0 jupyter_core==5.3.0 jupyter_server==2.5.0 jupyter_server_terminals==0.4.4 jupyterlab-pygments==0.2.2 kiwisolver==1.4.4 lazy_loader==0.2 lit==16.0.5.post0 llvmlite==0.39.1 locket==1.0.0 Markdown==3.4.3 MarkupSafe==2.1.2 matplotlib==3.7.1 matplotlib-inline==0.1.6 meme @ git+https://github.com/slaclab/meme/@af07afe431fa4503664aca8d9f83f786f85abbf0 mistune==2.0.5 mpmath==1.3.0 msgpack==1.0.5 multipledispatch==0.6.0 nbclassic==1.0.0 nbclient==0.7.4 nbconvert==7.3.1 nbformat==5.8.0 nest-asyncio==1.5.6 netCDF4==1.6.3 networkx==3.1 nose2==0.13.0 notebook==6.5.4 notebook_shim==0.2.3 numba==0.56.4 numpy==1.23.5 nvidia-cublas-cu11==11.10.3.66 nvidia-cuda-cupti-cu11==11.7.101 nvidia-cuda-nvrtc-cu11==11.7.99 nvidia-cuda-runtime-cu11==11.7.99 nvidia-cudnn-cu11==8.5.0.96 nvidia-cufft-cu11==10.9.0.58 nvidia-curand-cu11==10.2.10.91 nvidia-cusolver-cu11==11.4.0.1 nvidia-cusparse-cu11==11.7.4.91 nvidia-nccl-cu11==2.14.3 nvidia-nvtx-cu11==11.7.91 p4p==4.1.6 packaging==23.1 pandas==2.0.2 pandocfilters==1.5.0 panel==0.14.4 param==1.13.0 parso==0.8.3 partd==1.4.0 pexpect==4.8.0 pickleshare==0.7.5 Pillow==9.5.0 platformdirs==3.5.0 plotly==5.14.1 ply==3.11 pooch==1.7.0 prometheus-client==0.16.0 prompt-toolkit==3.0.38 protobuf==3.20.3 psutil==5.9.5 ptyprocess==0.7.0 pure-eval==0.2.2 pvxslibs==1.2.0 pyarrow==12.0.0 pycparser==2.21 pyct==0.5.0 Pygments==2.15.1 pyparsing==3.0.9 pyrsistent==0.19.3 python-dateutil==2.8.2 python-json-logger==2.0.7 pytz==2023.3 pyviz-comms==2.2.1 PyWavelets==1.4.1 PyYAML==6.0 pyzmq==25.0.2 ray==2.5.0 requests==2.31.0 rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 ruamel.yaml==0.17.31 ruamel.yaml.clib==0.2.7 scikit-image==0.20.0 scikit-learn==1.2.1 scipy==1.10.1 Send2Trash==1.8.2 setuptools-dso==2.8 shap==0.41.0 shapely==2.0.1 six==1.16.0 slicer==0.0.7 sniffio==1.3.0 soupsieve==2.4.1 stack-data==0.6.2 streamz==0.6.4 sympy==1.12 tenacity==8.2.2 tensorboardX==2.6 terminado==0.17.1 threadpoolctl==3.1.0 tifffile==2023.4.12 tinycss2==1.2.1 toolz==0.12.0 torch==2.0.1 torchvision==0.15.2 tornado==6.3.1 tqdm==4.65.0 traitlets==5.9.0 triton==2.0.0 typing_extensions==4.6.3 tzdata==2023.3 uri-template==1.2.0 urllib3==2.0.3 wcwidth==0.2.6 webcolors==1.13 webencodings==0.5.1 websocket-client==1.5.1 Werkzeug==2.3.3 xarray==2023.4.2 zict==3.0.0 zipp==3.15.0

finnoshea commented 1 year ago

It looks like p4p is trying to close _ClientProvider in python 3. This happens when python is exit()ed, so the garbage collector is going through and deling things but maybe the close method hasn't been implemented in p4p 4.1.6, so there is nothing to call.