Skip to content

Commit

Permalink
Merge pull request RedHatInsights#1074 from astrozzc/timeout
Browse files Browse the repository at this point in the history
Add two secs timeout
  • Loading branch information
astrozzc authored Apr 5, 2024
2 parents 33ddeb2 + 83cc6ab commit 6b4b6da
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion rbac/management/principal/cleaner.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def clean_principals_via_umb():
logger.info("clean_tenant_principals: Start principal clean up.")
UMB_CLIENT.connect()
UMB_CLIENT.subscribe(QUEUE, {StompSpec.ACK_HEADER: StompSpec.ACK_CLIENT_INDIVIDUAL})
while UMB_CLIENT.canRead(0): # Check if queue is empty
while UMB_CLIENT.canRead(2): # Check if queue is empty, two sec timeout
frame = UMB_CLIENT.receiveFrame()
data_dict = xmltodict.parse(frame.body)
is_deactivate = is_umb_deactivate_msg(data_dict)
Expand All @@ -186,6 +186,8 @@ def clean_principals_via_umb():
UMB_CLIENT.ack(frame)
continue
principal_name, groups = clean_principal_umb(data_dict)
if not groups:
logger.info(f"Principal {principal_name} was not under any groups.")
for tenant, group_names in groups.items():
logger.info(f"Principal {principal_name} was under tenant {tenant} in groups: {group_names}")
UMB_CLIENT.ack(frame) # This will remove the message from the queue
Expand Down

0 comments on commit 6b4b6da

Please sign in to comment.