@@ -42,6 +42,12 @@ def get_project(value: str) -> int | None:
42
42
API_TOKEN_TTL_IN_DAYS = 30
43
43
44
44
45
+ def debug_output (msg : str ) -> None :
46
+ if os .environ .get ("SENTRY_CLEANUP_SILENT" , None ):
47
+ return
48
+ click .echo (msg )
49
+
50
+
45
51
def multiprocess_worker (task_queue : _WorkQueue ) -> None :
46
52
# Configure within each Process
47
53
import logging
@@ -70,12 +76,15 @@ def multiprocess_worker(task_queue: _WorkQueue) -> None:
70
76
while True :
71
77
j = task_queue .get ()
72
78
if j == _STOP_WORKER :
79
+ debug_output ("Received STOP_WORKER task" )
73
80
task_queue .task_done ()
81
+
74
82
return
75
83
76
- model , chunk = j
77
- model = import_string ( model )
84
+ model_name , chunk = j
85
+ debug_output ( f"Starting deletion work for { model_name } : { chunk } " )
78
86
87
+ model = import_string (model_name )
79
88
try :
80
89
task = deletions .get (
81
90
model = model ,
@@ -85,11 +94,13 @@ def multiprocess_worker(task_queue: _WorkQueue) -> None:
85
94
)
86
95
87
96
while True :
97
+ debug_output (f"Running chunk for { model_name } " )
88
98
if not task .chunk ():
89
99
break
90
100
except Exception as e :
91
101
logger .exception (e )
92
102
finally :
103
+ debug_output (f"Completed deletion work for { model_name } :{ chunk } " )
93
104
task_queue .task_done ()
94
105
95
106
@@ -138,11 +149,8 @@ def cleanup(
138
149
raise click .Abort ()
139
150
140
151
os .environ ["_SENTRY_CLEANUP" ] = "1"
141
-
142
- def debug_output (msg : str ) -> None :
143
- if silent :
144
- return
145
- click .echo (msg )
152
+ if silent :
153
+ os .environ ["SENTRY_CLEANUP_SILENT" ] = "1"
146
154
147
155
# Make sure we fork off multiprocessing pool
148
156
# before we import or configure the app
@@ -368,6 +376,7 @@ def is_filtered(model: type[Model]) -> bool:
368
376
for chunk in q .iterator (chunk_size = 100 ):
369
377
task_queue .put ((imp , chunk ))
370
378
379
+ debug_output ("Waiting for task_queue to drain" )
371
380
task_queue .join ()
372
381
373
382
# Clean up FileBlob instances which are no longer used and aren't super
0 commit comments