mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-21 13:53:15 -07:00
Updates vendored subliminal to 2.1.0
Updates rarfile to 3.1 Updates stevedore to 3.5.0 Updates appdirs to 1.4.4 Updates click to 8.1.3 Updates decorator to 5.1.1 Updates dogpile.cache to 1.1.8 Updates pbr to 5.11.0 Updates pysrt to 1.1.2 Updates pytz to 2022.6 Adds importlib-metadata version 3.1.1 Adds typing-extensions version 4.1.1 Adds zipp version 3.11.0
This commit is contained in:
parent
d8da02cb69
commit
f05b09f349
694 changed files with 16621 additions and 11056 deletions
|
@ -1,5 +1,5 @@
|
|||
import time
|
||||
import logging
|
||||
import time
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
@ -11,10 +11,11 @@ class NeedRegenerationException(Exception):
|
|||
|
||||
"""
|
||||
|
||||
|
||||
NOT_REGENERATED = object()
|
||||
|
||||
|
||||
class Lock(object):
|
||||
class Lock:
|
||||
"""Dogpile lock class.
|
||||
|
||||
Provides an interface around an arbitrary mutex
|
||||
|
@ -70,8 +71,8 @@ class Lock(object):
|
|||
value is available."""
|
||||
|
||||
return not self._has_value(createdtime) or (
|
||||
self.expiretime is not None and
|
||||
time.time() - createdtime > self.expiretime
|
||||
self.expiretime is not None
|
||||
and time.time() - createdtime > self.expiretime
|
||||
)
|
||||
|
||||
def _has_value(self, createdtime):
|
||||
|
@ -109,7 +110,8 @@ class Lock(object):
|
|||
raise Exception(
|
||||
"Generation function should "
|
||||
"have just been called by a concurrent "
|
||||
"thread.")
|
||||
"thread."
|
||||
)
|
||||
else:
|
||||
return value
|
||||
|
||||
|
@ -122,9 +124,7 @@ class Lock(object):
|
|||
if self._has_value(createdtime):
|
||||
has_value = True
|
||||
if not self.mutex.acquire(False):
|
||||
log.debug(
|
||||
"creation function in progress "
|
||||
"elsewhere, returning")
|
||||
log.debug("creation function in progress elsewhere, returning")
|
||||
return NOT_REGENERATED
|
||||
else:
|
||||
has_value = False
|
||||
|
@ -173,8 +173,7 @@ class Lock(object):
|
|||
# there's no value at all, and we have to create it synchronously
|
||||
log.debug(
|
||||
"Calling creation function for %s value",
|
||||
"not-yet-present" if not has_value else
|
||||
"previously expired"
|
||||
"not-yet-present" if not has_value else "previously expired",
|
||||
)
|
||||
return self.creator()
|
||||
finally:
|
||||
|
@ -185,5 +184,5 @@ class Lock(object):
|
|||
def __enter__(self):
|
||||
return self._enter()
|
||||
|
||||
def __exit__(self, type, value, traceback):
|
||||
def __exit__(self, type_, value, traceback):
|
||||
pass
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue