Skip to content

Commit

Permalink
force channel layer to be empty
Browse files Browse the repository at this point in the history
since the version 4 of channel redis version, the channel layer is not
empty after the first read

we read it again to empty it

maybe it is related to
django/channels_redis#348
or to django/channels_redis#366
  • Loading branch information
clavay committed May 3, 2023
1 parent 6d0b47e commit 660b808
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pyscada/utils/scheduler.py
Expand Up @@ -845,7 +845,12 @@ async def waiting_action_receiver(self, dt, message):
self.dwt_received = True
if 'ProcessSignal' in a:
logger.debug("Received ProcessSignal %s on channel_layer for %s" % (a['ProcessSignal'], self.label))
#logger.debug(a)

# BUG : need to empty the channel_layer, if not the channel layer keep the message for each run loop
try:
await wait_for(self.channel_layer.receive(message), timeout=0.01)
except asyncioTimeoutError:
pass
else:
#logger.debug("sleep for %s - %s" % (self.process_id, dt))
sleep(dt)
Expand Down

0 comments on commit 660b808

Please sign in to comment.