fermi-ad / acsys-python

Python module to access the Fermilab Control System
MIT License
8 stars 4 forks source link

dpm.replies() doesn't start the list #80

Open beauremus opened 3 weeks ago

beauremus commented 3 weeks ago

Describe the bug I believe the expectation is that dpm.replies() can be called to provide an async generator. I don't think this makes sense if the list isn't started. Right now, this function doesn't ensure that the list is started.

To Reproduce Steps to reproduce the behavior:

#!/usr/bin/env python3

import sys
import acsys.dpm

async def my_app(con):
    # Setup context
    async with acsys.dpm.DPMContext(con) as dpm:
        # Add acquisition requests
        await dpm.add_entry(0, "M:OUTTMP")

        # This code doesn't work without this next line
        # dpm.start()

        # Process incoming data
        async for evt_res in dpm.replies():
            if evt_res.isReading:
                print(evt_res)
            else:
                print(f"ERROR: {evt_res}")

acsys.run_client(my_app)

This runs but hangs because there are never messages, and we never start the list.

Expected behavior See above

Environment (please complete the following information):