Skip to content

Commit

Permalink
Merge pull request RedHatInsights#1170 from astrozzc/catch_error
Browse files Browse the repository at this point in the history
Catch error if already subscribed
  • Loading branch information
astrozzc authored Aug 15, 2024
2 parents 28f982e + d24f354 commit c85ecb1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions rbac/management/principal/cleaner.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,12 @@ def clean_principals_via_umb():
logger.info("clean_tenant_principals: Start principal clean up via umb.")
try:
UMB_CLIENT.connect()
UMB_CLIENT.subscribe(QUEUE, {StompSpec.ACK_HEADER: StompSpec.ACK_CLIENT_INDIVIDUAL})
except StompConnectionError as e:
# Skip if already connected
if not str(e).startswith("Already connected"):
# Skip if already connected/subscribed
if not str(e).startswith(("Already connected", "Already subscribed")):
raise e

UMB_CLIENT.subscribe(QUEUE, {StompSpec.ACK_HEADER: StompSpec.ACK_CLIENT_INDIVIDUAL})
while UMB_CLIENT.canRead(2): # Check if queue is empty, two sec timeout
frame = UMB_CLIENT.receiveFrame()
data_dict = xmltodict.parse(frame.body)
Expand Down

0 comments on commit c85ecb1

Please sign in to comment.