DiamondLightSource / aioca

Asynchronous Channel Access client for asyncio and Python using libca via ctypes
Apache License 2.0
6 stars 3 forks source link

Add PVCache #13

Open mdavidsaver opened 3 years ago

mdavidsaver commented 3 years ago

Maybe useful in some form. I've found myself writing something like this in many CA client scripts. Meant to be used something like camontor(). Instead of Subscriptions, returns an object which can be iterated to yield snapshots of cache values whenever there is an update.

await for val1, val2 in PVCache(['pv1', 'pv2']):
    print(val1, '+', val2, '=', val1+val2)

Or with a larger number of PVs, a dictionary mode.

await for V in PVCache({'A':'pv1', 'B':'pv2'}):
    print(V['A'], '+', V['B'], '=', V['A']+V['B'])
mdavidsaver commented 3 years ago

I clicked Create too soon. Description updated...

Araneidae commented 3 years ago

There is the cothread.pv.PV object in cothread. Does this cover the same ground? If so, this could readily be transferred across.

mdavidsaver commented 3 years ago

Unrelated to the code, but since I noticed your usage yesterday when I needed to enable GHA builds for my fork. fyi. It is being reported that this Action was doing nefarious things for several months this spring.

https://github.com/dls-controls/aioca/blob/853e28b6c717c14db730d5e2e3ad5719c744a9ae/.github/workflows/code.yml#L84-L87

thomascobb commented 3 years ago

Yes, we had to re-roll our PyPI token because of this...