Skip to content

Commit 30518a0

Browse files
committed
Make return_messages application private
1 parent 4badcb3 commit 30518a0

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

cqc/MessageHandler.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,6 @@ def __init__(self, factory):
180180
self.name = factory.name
181181
self.return_messages = defaultdict(list) # Dictionary of all cqc messages to return per app_id
182182

183-
# List of all cqc messages to return
184-
self.return_messages = []
185-
186183
# Dictionary that stores all reference ids and their values privately for each app_id.
187184
# Query/assign like this: self.references[app_id][ref_id]
188185
self.references = defaultdict(dict)
@@ -418,15 +415,15 @@ def handle_mix(self, header: CQCHeader, data: bytes):
418415
# Notice the [:] syntax. This ensures the underlying list is updated, and not just the variable.
419416

420417
return_message = None
421-
for message in self.return_messages:
418+
for message in self.return_messages[header.app_id]:
422419
if is_error_message(message):
423420
return_message = message
424421
break
425422

426423
if return_message is None:
427424
return_message = self.create_return_message(header.app_id, CQCType.DONE, cqc_version=header.version)
428425

429-
self.return_messages[:] = [return_message]
426+
self.return_messages[header.app_id][:] = [return_message]
430427

431428
# The other handlers from self.message_handlers return a bool that indicates whether
432429
# self.handle_cqc_message should append a TP_DONE message. This handle_mix method does that itself
@@ -454,7 +451,7 @@ def handle_conditional(self, header: CQCHeader, data: bytes):
454451
# If one of the above lookups in self.references fails because the queried reference IDs haven't
455452
# been assigned earlier, a KeyError will be raised
456453
except KeyError:
457-
self.return_messages.append(
454+
self.return_messages[header.app_id].append(
458455
self.create_return_message(header.app_id, CQC_ERR_GENERAL, cqc_version=header.version)
459456
)
460457
# Since the referenced IDs don't exist, we consider this IF-statement to evaluate to False.

0 commit comments

Comments
 (0)