changed to asyncio

This commit is contained in:
2024-06-06 16:15:40 +02:00
parent 953ce673e0
commit 409ddd22e8
2 changed files with 6 additions and 93 deletions
+5 -3
View File
@@ -4,6 +4,7 @@ from typing import Tuple, Optional
from itertools import cycle, islice
import re
import time
import asyncio
from collections import deque
import click
@@ -228,7 +229,7 @@ def plot(channels, start_time=0, in_subplots=False, marker="hd"):
plt.show()
def runner(
async def runner(
channels: dict, acquire_interval=0.1, plot_interval=1, in_subplots=False, abort=False, relative_time=True
):
"""
@@ -266,7 +267,7 @@ def runner(
sleep_time = max(0, acquire_interval - elapsed_collect)
time.sleep(sleep_time) # should be faster than 100 Hz for BS data
await asyncio.sleep(sleep_time) # should be faster than 100 Hz for BS data
@click.command()
@@ -284,8 +285,9 @@ def main(
):
""" Plot channels from BS (beam synchronous) or PV (EPICS) sources. """
channels = {channel: ChannelData(channel, save_file_prefix=save_prefix) for channel in channel_names}
runner(channels, acquire_interval=float(acquire_interval), plot_interval=plot_interval, in_subplots=in_subplots)
asyncio.run(runner(channels, acquire_interval=float(acquire_interval), plot_interval=plot_interval, in_subplots=in_subplots))
if __name__ == "__main__":
main()