Skip to content

Commit

Permalink
try to fix multiple user limits (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
francesconazzaro committed Jul 26, 2024
1 parent 1b3b72a commit dc4d0c5
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions cads_broker/qos/QoS.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,20 +253,22 @@ def user_limit(self, request):
user = request.user_uid

limits = self.per_user_limits.get(user, [])
if limits != []:
print(user, limits)
return limits
applied_limits = []
for limit in limits:
if limit.match(request):
applied_limits.append(limit)

for limit in self.rules.user_limits:
if limit.match(request):
"""
We clone the rule because we need one instance per different
user otherwise all users will share that limit
"""
limit = limit.clone()
limits.append(limit)
self.per_user_limits[user] = limits
return limits
if limit.get_uid(request) not in [l.get_uid(request) for l in limits]:
limit = limit.clone()
applied_limits.append(limit)
self.per_user_limits[user] = self.per_user_limits.get(user, []) + [limit]
return applied_limits

@locked
def pick(self, queue, session):
Expand Down

0 comments on commit dc4d0c5

Please sign in to comment.