Skip to content

Commit dc4d0c5

Browse files
try to fix multiple user limits (#124)
1 parent 1b3b72a commit dc4d0c5

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

cads_broker/qos/QoS.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -253,20 +253,22 @@ def user_limit(self, request):
253253
user = request.user_uid
254254

255255
limits = self.per_user_limits.get(user, [])
256-
if limits != []:
257-
print(user, limits)
258-
return limits
256+
applied_limits = []
257+
for limit in limits:
258+
if limit.match(request):
259+
applied_limits.append(limit)
259260

260261
for limit in self.rules.user_limits:
261262
if limit.match(request):
262263
"""
263264
We clone the rule because we need one instance per different
264265
user otherwise all users will share that limit
265266
"""
266-
limit = limit.clone()
267-
limits.append(limit)
268-
self.per_user_limits[user] = limits
269-
return limits
267+
if limit.get_uid(request) not in [l.get_uid(request) for l in limits]:
268+
limit = limit.clone()
269+
applied_limits.append(limit)
270+
self.per_user_limits[user] = self.per_user_limits.get(user, []) + [limit]
271+
return applied_limits
270272

271273
@locked
272274
def pick(self, queue, session):

0 commit comments

Comments
 (0)