File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change 33import enum
44import logging
55from collections .abc import Iterable
6+ from concurrent .futures import ThreadPoolExecutor
67
78import click
89from sqlalchemy .orm import Query
@@ -126,6 +127,8 @@ def run(
126127 assert batch_size > 0
127128 assert delete_batch_size > 0
128129
130+ delete_executor = ThreadPoolExecutor (max_workers = 10 )
131+
129132 for repetition in range (repeat ):
130133 blocks = find_blocks (
131134 limit ,
@@ -167,7 +170,7 @@ def run(
167170 delete_sha256s .add (block .data_sha256 )
168171
169172 if len (delete_sha256s ) >= delete_batch_size :
170- delete_batch ( delete_sha256s , dry_run )
173+ delete_executor . submit ( delete_batch , delete_sha256s . copy () , dry_run )
171174 delete_sha256s .clear ()
172175
173176 delete_batch (delete_sha256s , dry_run )
@@ -177,6 +180,8 @@ def run(
177180
178181 after_id = max_id + 1
179182
183+ delete_executor .shutdown (wait = True )
184+
180185
181186if __name__ == "__main__" :
182187 run ()
You can’t perform that action at this time.
0 commit comments