Skip chunking, rely solely on trio
This commit is contained in:
parent
4facb64bf8
commit
dc63cac8aa
@ -15,7 +15,6 @@ from xml.etree import ElementTree as ET
|
|||||||
import asks
|
import asks
|
||||||
import html5lib
|
import html5lib
|
||||||
import trio
|
import trio
|
||||||
from tqdm import tqdm
|
|
||||||
|
|
||||||
from etherpump.commands.common import * # noqa
|
from etherpump.commands.common import * # noqa
|
||||||
from etherpump.commands.html5tidy import html5tidy
|
from etherpump.commands.html5tidy import html5tidy
|
||||||
@ -446,16 +445,6 @@ async def handle_pad(args, padid, data, info, session):
|
|||||||
await f.write(json.dumps(meta))
|
await f.write(json.dumps(meta))
|
||||||
|
|
||||||
|
|
||||||
async def handle_pad_chunk(args, padids, data, info, session):
|
|
||||||
progress_kwargs = {}
|
|
||||||
if not istty():
|
|
||||||
progress_kwargs.update(dict(disable=True))
|
|
||||||
|
|
||||||
padids = tqdm(iterable=padids, total=len(padids), **progress_kwargs,)
|
|
||||||
for padid in padids:
|
|
||||||
await handle_pad(args, padid, data, info, session)
|
|
||||||
|
|
||||||
|
|
||||||
async def handle_pads(args):
|
async def handle_pads(args):
|
||||||
session = asks.Session(connections=args.connection)
|
session = asks.Session(connections=args.connection)
|
||||||
info = loadpadinfo(args.padinfo)
|
info = loadpadinfo(args.padinfo)
|
||||||
@ -464,12 +453,11 @@ async def handle_pads(args):
|
|||||||
padids = await get_padids(args, info, data, session)
|
padids = await get_padids(args, info, data, session)
|
||||||
if args.skip:
|
if args.skip:
|
||||||
padids = padids[args.skip : len(padids)]
|
padids = padids[args.skip : len(padids)]
|
||||||
CHUNK_SIZE = math.ceil(len(padids) / 3)
|
|
||||||
|
|
||||||
async with trio.open_nursery() as nursery:
|
async with trio.open_nursery() as nursery:
|
||||||
for padids in chunks(padids, CHUNK_SIZE):
|
print("Processing {} pads now...".format(len(padids)))
|
||||||
_args = (args, padids, data, info, session)
|
for padid in padids:
|
||||||
nursery.start_soon(handle_pad_chunk, *_args)
|
nursery.start_soon(handle_pad, args, padid, data, info, session)
|
||||||
|
|
||||||
|
|
||||||
def main(args):
|
def main(args):
|
||||||
|
Loading…
Reference in New Issue
Block a user