Skip to content

Commit a5731b2

Browse files
author
Hugo Osvaldo Barrera
authored
Merge pull request #913 from pimutils/async-collections
Sync pairs asynchronously
2 parents 459efbf + 177748d commit a5731b2

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

vdirsyncer/cli/__init__.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,20 +129,24 @@ def sync(ctx, collections, force_delete):
129129
async def main(collections):
130130
conn = aiohttp.TCPConnector(limit_per_host=16)
131131

132+
tasks = []
132133
for pair_name, collections in collections:
133134
async for collection, config in prepare_pair(
134135
pair_name=pair_name,
135136
collections=collections,
136137
config=ctx.config,
137138
connector=conn,
138139
):
139-
await sync_collection(
140-
collection=collection,
141-
general=config,
142-
force_delete=force_delete,
143-
connector=conn,
140+
tasks.append(
141+
sync_collection(
142+
collection=collection,
143+
general=config,
144+
force_delete=force_delete,
145+
connector=conn,
146+
)
144147
)
145148

149+
await asyncio.gather(*tasks)
146150
await conn.close()
147151

148152
asyncio.run(main(collections))

0 commit comments

Comments
 (0)