Skip to content

Commit

Permalink
Replace the status lock with a semaphore with a limit of 5
Browse files Browse the repository at this point in the history
  • Loading branch information
albireox committed Dec 5, 2024
1 parent a4e2173 commit 2b54b0b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion python/lvmecp/actor/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def __init__(
else:
self.plc = plc

self.lock = asyncio.Lock()
self.semaphore = asyncio.Semaphore(5)

async def start(self, **kwargs):
"""Starts the actor."""
Expand Down
18 changes: 9 additions & 9 deletions python/lvmecp/actor/commands/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ async def status(command: ECPCommand, no_registers: bool = False):

plc = command.actor.plc

async with command.actor.lock:
if no_registers is False:
if no_registers is False:
async with command.actor.semaphore:
command.info(registers=(await plc.read_all_registers(use_cache=False)))

modules: list[PLCModule] = [plc.dome, plc.safety, plc.lights]
await asyncio.gather(
*[
module.update(force_output=True, command=command, use_cache=True)
for module in modules
]
)
modules: list[PLCModule] = [plc.dome, plc.safety, plc.lights]
await asyncio.gather(
*[
module.update(force_output=True, command=command, use_cache=True)
for module in modules
]
)

command.info(
o2_percent_utilities=plc.safety.o2_level_utilities,
Expand Down

0 comments on commit 2b54b0b

Please sign in to comment.