utils: removed dead function batch() (#74727)
gitea/authentic/pipeline/head This commit looks good Details

This commit is contained in:
Benjamin Dauvergne 2023-02-21 17:48:03 +01:00 committed by Gitea
parent de60d04f36
commit 9b5aabb690
1 changed files with 1 additions and 13 deletions

View File

@ -24,7 +24,7 @@ import urllib.parse
import uuid
from functools import wraps
from importlib import import_module
from itertools import chain, count, islice
from itertools import count
import phonenumbers
from django import forms
@ -965,18 +965,6 @@ def send_password_reset_mail(
)
def batch(iterable, size):
"""Batch an iterable as an iterable of iterables of at most size element
long.
"""
sourceiter = iter(iterable)
while True:
batchiter = islice(sourceiter, size)
# call next() at least one time to advance, if the caller does not
# consume the returned iterators, sourceiter will never be exhausted.
yield chain([batchiter.next()], batchiter)
def batch_queryset(qs, size=1000, progress_callback=None):
"""Batch prefetched potentially very large queryset, it's a middle ground
between using .iterator() which cannot be prefetched and prefetching a full