Skip to content

Commit

Permalink
Merge branch 'release/2.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
wolph committed Mar 28, 2021
2 parents 061837e + e99c2d6 commit ec9f5da
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion portalocker/__about__.py
@@ -1,7 +1,7 @@
__package_name__ = 'portalocker'
__author__ = 'Rick van Hattem'
__email__ = 'wolph@wol.ph'
__version__ = '2.2.1'
__version__ = '2.3.0'
__description__ = '''Wraps the portalocker recipe for easy usage'''
__url__ = 'https://github.com/WoLpH/portalocker'

2 changes: 1 addition & 1 deletion portalocker/__init__.py
Expand Up @@ -17,7 +17,7 @@
#: Current author's email address
__email__ = __about__.__email__
#: Version number
__version__ = '2.2.1'
__version__ = '2.3.0'
#: Package description for Pypi
__description__ = __about__.__description__
#: Package homepage
Expand Down
Empty file added portalocker/py.typed
Empty file.
2 changes: 1 addition & 1 deletion portalocker/redis.py
Expand Up @@ -152,7 +152,7 @@ def acquire(
self.unavailable_timeout): # pragma: no branch
continue
else: # pragma: no cover
subscribers = None
subscribers = 0

# Note: this should not be changed to an elif because the if
# above can still end up here
Expand Down
12 changes: 7 additions & 5 deletions portalocker/utils.py
Expand Up @@ -7,11 +7,14 @@
import tempfile
import time
import typing
import logging

from . import constants
from . import exceptions
from . import portalocker

logger = logging.getLogger(__name__)

DEFAULT_TIMEOUT = 5
DEFAULT_CHECK_INTERVAL = 0.25
DEFAULT_FAIL_WHEN_LOCKED = False
Expand Down Expand Up @@ -397,10 +400,9 @@ def acquire(
assert not self.lock, 'Already locked'

filenames = self.get_filenames()
print('filenames', filenames)

for _ in self._timeout_generator(timeout, check_interval): # pragma:
print('trying lock', filenames)
for n in self._timeout_generator(timeout, check_interval): # pragma:
logger.debug('trying lock (attempt %d) %r', n, filenames)
# no branch
if self.try_lock(filenames): # pragma: no branch
return self.lock # pragma: no cover
Expand All @@ -410,11 +412,11 @@ def acquire(
def try_lock(self, filenames: typing.Sequence[Filename]) -> bool:
filename: Filename
for filename in filenames:
print('trying lock for', filename)
logger.debug('trying lock for %r', filename)
self.lock = Lock(filename, fail_when_locked=True)
try:
self.lock.acquire()
print('locked', filename)
logger.debug('locked %r', filename)
return True
except exceptions.AlreadyLocked:
pass
Expand Down
1 change: 1 addition & 0 deletions setup.py
Expand Up @@ -126,6 +126,7 @@ def run(self):
author_email=about['__email__'],
url=about['__url__'],
license='PSF',
package_data=dict(portalocker=['py.typed']),
packages=setuptools.find_packages(exclude=[
'examples', 'portalocker_tests']),
# zip_safe=False,
Expand Down

0 comments on commit ec9f5da

Please sign in to comment.