From 738ebe80407a5f991b6279c7f6c9a7bef248e48f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Wed, 11 Jan 2023 23:40:41 +0200 Subject: [PATCH] Use asyncio.gather for sync tasks --- plextraktsync/sync.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/plextraktsync/sync.py b/plextraktsync/sync.py index 8b895be78bb..406298e9bd3 100644 --- a/plextraktsync/sync.py +++ b/plextraktsync/sync.py @@ -1,5 +1,6 @@ from __future__ import annotations +import asyncio from typing import TYPE_CHECKING from plextraktsync.decorators.cached_property import cached_property @@ -133,17 +134,21 @@ async def sync(self, walker: Walker, dry_run=False): if self.config.need_library_walk: async for movie in walker.find_movies(): - await self.sync_collection(movie, dry_run=dry_run) - await self.sync_ratings(movie, dry_run=dry_run) - await self.sync_watched(movie, dry_run=dry_run) + await asyncio.gather(*[ + self.sync_collection(movie, dry_run=dry_run), + self.sync_ratings(movie, dry_run=dry_run), + self.sync_watched(movie, dry_run=dry_run), + ]) if not is_partial: listutil.addPlexItemToLists(movie) shows = set() async for episode in walker.find_episodes(): - await self.sync_collection(episode, dry_run=dry_run) - await self.sync_ratings(episode, dry_run=dry_run) - await self.sync_watched(episode, dry_run=dry_run) + await asyncio.gather(*[ + self.sync_collection(episode, dry_run=dry_run), + self.sync_ratings(episode, dry_run=dry_run), + self.sync_watched(episode, dry_run=dry_run), + ]) if not is_partial: listutil.addPlexItemToLists(episode) if self.config.sync_ratings: