Skip to content

Commit

Permalink
enumerate() is fine here
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiask committed Jun 26, 2024
1 parent 86eacf3 commit bad355d
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions imagefield/management/commands/process_imagefields.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ def _process_field(self, field, options):
force=options.get("force"),
)

index = 0
fn = partial(
self._process_instance,
field=field,
Expand All @@ -96,9 +95,9 @@ def _process_field(self, field, options):
)

with ThreadPoolExecutor() as executor:
for instance in executor.map(fn, queryset.iterator(chunk_size=100)):
index += 1

for index, instance in enumerate(
executor.map(fn, queryset.iterator(chunk_size=100))
):
progress = "*" * (50 * index // count)
self.stdout.write(
f"\r|{progress.ljust(50)}| {index + 1}/{count}", ending=""
Expand Down

0 comments on commit bad355d

Please sign in to comment.