Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Commit

Permalink
Change loop interval to 500ms to reduce CPU usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Caleb9 committed Jan 31, 2023
1 parent 3e336d9 commit aa1591f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


class App(tkinter.Tk):
MONITOR_LOOP_INTERVAL = 100
_MONITOR_LOOP_INTERVAL = 500

def __init__(
self,
Expand Down Expand Up @@ -46,7 +46,7 @@ def _monitor(
last_photo_change: datetime.datetime,
thread: get_photo_thread.GetPhotoThread) -> None:
def schedule_next_iteration() -> None:
self.after(self.MONITOR_LOOP_INTERVAL,
self.after(self._MONITOR_LOOP_INTERVAL,
lambda: self._monitor(last_photo_change, thread))

if thread.is_alive():
Expand All @@ -65,7 +65,7 @@ def schedule_next_iteration() -> None:
return

if self._datetime_now() - last_photo_change < self._photo_change_interval:
# Current photo is still being displayed. Wait for another 100 ms.
# Current photo is still being displayed. Wait for another 500 ms.
schedule_next_iteration()
return
# Next photo is ready and current photo has been shown for required duration. Show next photo and start fetching
Expand Down
4 changes: 2 additions & 2 deletions slideshow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@


class Slideshow:
_PHOTOS_BATCH_SIZE = 10

def __init__(
self,
photos_client: synology_photos_client.PhotosClient):
Expand All @@ -10,8 +12,6 @@ def __init__(
self._photos_batch: list[synology_photos_client.PhotosClient.PhotoDto] = []
self._batch_photo_index = 0

_PHOTOS_BATCH_SIZE = 10

def get_next_photo(self) -> bytes:
if self._slideshow_ended():
self._album_offset = 0
Expand Down

0 comments on commit aa1591f

Please sign in to comment.