Skip to content

Commit

Permalink
Class locks
Browse files Browse the repository at this point in the history
  • Loading branch information
MoojMidge committed Dec 25, 2022
1 parent e98d624 commit a7adb18
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion resources/lib/monitor/itemdetails.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@


class ListItemDetails():
_lock = Lock()

def __init__(self, parent, position=0):
self._lock = Lock()
self._parent = parent
self._position = position
self._season = None
Expand Down
3 changes: 2 additions & 1 deletion resources/lib/monitor/listitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,8 @@ def get_readahead(self):

# Readahead next item and if the main item changes in the meantime we reset to None
def _next_readahead():
if self._readahead.next_readahead() != READAHEAD_CHANGED:
readahead = self._readahead if self._readahead else None
if not readahead or readahead.next_readahead() != READAHEAD_CHANGED:
return
self._readahead = None

Expand Down
5 changes: 2 additions & 3 deletions resources/lib/monitor/readahead.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@


class ListItemReadAhead():
_lock = Lock()

def __init__(self, parent, cur_window, cur_item):
self._lock = Lock()
self._parent = parent
self._pre_window = cur_window
self._pre_item = cur_item
Expand Down Expand Up @@ -49,8 +50,6 @@ def _next_readahead(self):
return READAHEAD_COMPLETED

def next_readahead(self):
if self._lock.locked():
return None
with self._lock:
status = self._next_readahead()
return status

0 comments on commit a7adb18

Please sign in to comment.