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
@@ -122,6 +123,8 @@ def run(
122123 assert batch_size > 0
123124 assert delete_batch_size > 0
124125
126+ delete_executor = ThreadPoolExecutor (max_workers = 10 )
127+
125128 for repetition in range (repeat ):
126129 blocks = find_blocks (
127130 limit ,
@@ -163,7 +166,7 @@ def run(
163166 delete_sha256s .add (block .data_sha256 )
164167
165168 if len (delete_sha256s ) >= delete_batch_size :
166- delete_batch ( delete_sha256s , dry_run )
169+ delete_executor . submit ( delete_batch , delete_sha256s . copy () , dry_run )
167170 delete_sha256s .clear ()
168171
169172 delete_batch (delete_sha256s , dry_run )
@@ -173,6 +176,8 @@ def run(
173176
174177 after_id = max_id + 1
175178
179+ delete_executor .shutdown (wait = True )
180+
176181
177182if __name__ == "__main__" :
178183 run ()
You can’t perform that action at this time.
0 commit comments