Skip to content

Commit

Permalink
Use asyncio.gather for sync tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
glensc committed Jan 11, 2023
1 parent c4b52c8 commit 738ebe8
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions plextraktsync/sync.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import asyncio
from typing import TYPE_CHECKING

from plextraktsync.decorators.cached_property import cached_property
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 738ebe8

Please sign in to comment.