Skip to content

multiple user limits for each user #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions cads_broker/qos/QoS.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ def _properties(self, request, session):
properties.limits.append(rule)

# Add per-user limits
limit = self.user_limit(request)
if limit is not None:
properties.limits.append(limit)
limits = self.user_limit(request)
if limits != []:
properties.limits.extend(limits)

# Add priorities and compute starting priority
priority = 0
Expand Down Expand Up @@ -252,10 +252,10 @@ def user_limit(self, request):
"""Return the per-user limit for the user associated with the request."""
user = request.user_uid

limit = self.per_user_limits.get(user)
if limit is not None:
print(user, limit)
return limit
limits = self.per_user_limits.get(user, [])
if limits != []:
print(user, limits)
return limits

for limit in self.rules.user_limits:
if limit.match(request):
Expand All @@ -264,10 +264,9 @@ def user_limit(self, request):
user otherwise all users will share that limit
"""
limit = limit.clone()
self.per_user_limits[user] = limit
return limit
return None
# raise Exception(f"Not rules matching user '{user}'")
limits.append(limit)
self.per_user_limits[user] = limits
return limits

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