@@ -652,20 +652,20 @@ async def group_send(self, group, message):
652
652
# stored in channel_to_message dict and contains the
653
653
# __asgi_channel__ key.
654
654
655
- group_send_lua = """ local over_capacity = 0
656
- for i=1,#KEYS do
657
- if redis.call('ZCOUNT', KEYS[i], '-inf', '+inf') < tonumber(ARGV[i + #KEYS]) then
658
- redis.call('ZADD', KEYS[i], %f, ARGV[i])
659
- redis.call('EXPIRE', KEYS[i], %d)
660
- else
661
- over_capacity = over_capacity + 1
662
- end
655
+ group_send_lua = """
656
+ local over_capacity = 0
657
+ local current_time = ARGV[#ARGV - 1]
658
+ local expiry = ARGV[#ARGV]
659
+ for i=1,#KEYS do
660
+ if redis.call('ZCOUNT', KEYS[i], '-inf', '+inf') < tonumber(ARGV[i + #KEYS]) then
661
+ redis.call('ZADD', KEYS[i], current_time, ARGV[i])
662
+ redis.call('EXPIRE', KEYS[i], expiry)
663
+ else
664
+ over_capacity = over_capacity + 1
663
665
end
664
- return over_capacity
665
- """ % (
666
- time .time (),
667
- self .expiry ,
668
- )
666
+ end
667
+ return over_capacity
668
+ """
669
669
670
670
# We need to filter the messages to keep those related to the connection
671
671
args = [
@@ -679,6 +679,8 @@ async def group_send(self, group, message):
679
679
for channel_key in channel_redis_keys
680
680
]
681
681
682
+ args += [time .time (), self .expiry ]
683
+
682
684
# channel_keys does not contain a single redis key more than once
683
685
async with self .connection (connection_index ) as connection :
684
686
channels_over_capacity = await connection .eval (
0 commit comments