Skip to content
Open
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: 16 additions & 5 deletions buggy_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,21 @@ def process_data():
is_processing = True
count = 0

while is_processing:
count += 1
if count == 100:
print("Data processed.")
is_processing = False # Terminate the loop
try:
while is_processing:
count += 1
if count == 100:
print("Data processed.")
is_processing = False # Terminate the loop
finally:
# Explicitly dereference local variables to ensure they are eligible for
# garbage collection as soon as possible. While often redundant for simple
# types and Python's default scope management, this can act as a defensive
# measure in scenarios where variables might unexpectedly hold references
# to larger objects or external resources that need prompt release.
if 'is_processing' in locals():
del is_processing
if 'count' in locals():
del count

process_data()