commit python-filelock for openSUSE:Factory
Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-filelock for openSUSE:Factory checked in at 2024-05-03 19:44:14 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-filelock (Old) and /work/SRC/openSUSE:Factory/.python-filelock.new.1880 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "python-filelock" Fri May 3 19:44:14 2024 rev:19 rq:1171540 version:3.14.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-filelock/python-filelock.changes 2024-04-21 20:25:17.837553945 +0200 +++ /work/SRC/openSUSE:Factory/.python-filelock.new.1880/python-filelock.changes 2024-05-03 19:44:21.780443991 +0200 @@ -1,0 +2,7 @@ +Fri May 3 07:35:30 UTC 2024 - Dirk Müller <dmueller@suse.com> + +- update to 3.14.0: + * feat: `blocking` parameter on lock constructor with tests and + docs + +------------------------------------------------------------------- Old: ---- filelock-3.13.4.tar.gz New: ---- filelock-3.14.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-filelock.spec ++++++ --- /var/tmp/diff_new_pack.jVySII/_old 2024-05-03 19:44:22.344464497 +0200 +++ /var/tmp/diff_new_pack.jVySII/_new 2024-05-03 19:44:22.348464642 +0200 @@ -19,7 +19,7 @@ %{?sle15_python_module_pythons} Name: python-filelock -Version: 3.13.4 +Version: 3.14.0 Release: 0 Summary: Platform Independent File Lock in Python License: Unlicense ++++++ filelock-3.13.4.tar.gz -> filelock-3.14.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/filelock-3.13.4/PKG-INFO new/filelock-3.14.0/PKG-INFO --- old/filelock-3.13.4/PKG-INFO 2020-02-02 01:00:00.000000000 +0100 +++ new/filelock-3.14.0/PKG-INFO 2020-02-02 01:00:00.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.3 Name: filelock -Version: 3.13.4 +Version: 3.14.0 Summary: A platform independent file lock. Project-URL: Documentation, https://py-filelock.readthedocs.io Project-URL: Homepage, https://github.com/tox-dev/py-filelock diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/filelock-3.13.4/src/filelock/_api.py new/filelock-3.14.0/src/filelock/_api.py --- old/filelock-3.13.4/src/filelock/_api.py 2020-02-02 01:00:00.000000000 +0100 +++ new/filelock-3.14.0/src/filelock/_api.py 2020-02-02 01:00:00.000000000 +0100 @@ -63,6 +63,9 @@ #: The mode for the lock files mode: int + #: Whether the lock should be blocking or not + blocking: bool + #: The file descriptor for the *_lock_file* as it is returned by the os.open() function, not None when lock held lock_file_fd: int | None = None @@ -86,6 +89,7 @@ mode: int = 0o644, thread_local: bool = True, # noqa: ARG003, FBT001, FBT002 *, + blocking: bool = True, # noqa: ARG003 is_singleton: bool = False, **kwargs: dict[str, Any], # capture remaining kwargs for subclasses # noqa: ARG003 ) -> Self: @@ -115,6 +119,7 @@ mode: int = 0o644, thread_local: bool = True, # noqa: FBT001, FBT002 *, + blocking: bool = True, is_singleton: bool = False, ) -> None: """ @@ -127,6 +132,7 @@ :param mode: file permissions for the lockfile :param thread_local: Whether this object's internal context should be thread local or not. If this is set to \ ``False`` then the lock will be reentrant across threads. + :param blocking: whether the lock should be blocking or not :param is_singleton: If this is set to ``True`` then only one instance of this class will be created \ per lock file. This is useful if you want to use the lock object for reentrant locking without needing \ to pass the same object around. @@ -135,12 +141,13 @@ self._is_thread_local = thread_local self._is_singleton = is_singleton - # Create the context. Note that external code should not work with the context directly and should instead use + # Create the context. Note that external code should not work with the context directly and should instead use # properties of this class. kwargs: dict[str, Any] = { "lock_file": os.fspath(lock_file), "timeout": timeout, "mode": mode, + "blocking": blocking, } self._context: FileLockContext = (ThreadLocalFileContext if thread_local else FileLockContext)(**kwargs) @@ -178,6 +185,21 @@ self._context.timeout = float(value) @property + def blocking(self) -> bool: + """:return: whether the locking is blocking or not""" + return self._context.blocking + + @blocking.setter + def blocking(self, value: bool) -> None: + """ + Change the default blocking value. + + :param value: the new value as bool + + """ + self._context.blocking = value + + @property def mode(self) -> int: """:return: the file permissions for the lockfile""" return self._context.mode @@ -215,7 +237,7 @@ poll_interval: float = 0.05, *, poll_intervall: float | None = None, - blocking: bool = True, + blocking: bool | None = None, ) -> AcquireReturnProxy: """ Try to acquire the file lock. @@ -252,6 +274,9 @@ if timeout is None: timeout = self._context.timeout + if blocking is None: + blocking = self._context.blocking + if poll_intervall is not None: msg = "use poll_interval instead of poll_intervall" warnings.warn(msg, DeprecationWarning, stacklevel=2) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/filelock-3.13.4/src/filelock/version.py new/filelock-3.14.0/src/filelock/version.py --- old/filelock-3.13.4/src/filelock/version.py 2020-02-02 01:00:00.000000000 +0100 +++ new/filelock-3.14.0/src/filelock/version.py 2020-02-02 01:00:00.000000000 +0100 @@ -12,5 +12,5 @@ __version_tuple__: VERSION_TUPLE version_tuple: VERSION_TUPLE -__version__ = version = '3.13.4' -__version_tuple__ = version_tuple = (3, 13, 4) +__version__ = version = '3.14.0' +__version_tuple__ = version_tuple = (3, 14, 0) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/filelock-3.13.4/tests/test_filelock.py new/filelock-3.14.0/tests/test_filelock.py --- old/filelock-3.13.4/tests/test_filelock.py 2020-02-02 01:00:00.000000000 +0100 +++ new/filelock-3.14.0/tests/test_filelock.py 2020-02-02 01:00:00.000000000 +0100 @@ -303,11 +303,17 @@ # raises Timeout error when the lock cannot be acquired lock_path = tmp_path / "a" lock_1, lock_2 = lock_type(str(lock_path)), lock_type(str(lock_path)) + lock_3 = lock_type(str(lock_path), blocking=False) + lock_4 = lock_type(str(lock_path), timeout=0) + lock_5 = lock_type(str(lock_path), blocking=False, timeout=-1) # acquire lock 1 lock_1.acquire() assert lock_1.is_locked assert not lock_2.is_locked + assert not lock_3.is_locked + assert not lock_4.is_locked + assert not lock_5.is_locked # try to acquire lock 2 with pytest.raises(Timeout, match="The file lock '.*' could not be acquired."): @@ -315,10 +321,50 @@ assert not lock_2.is_locked assert lock_1.is_locked + # try to acquire pre-parametrized `blocking=False` lock 3 with `acquire` + with pytest.raises(Timeout, match="The file lock '.*' could not be acquired."): + lock_3.acquire() + assert not lock_3.is_locked + assert lock_1.is_locked + + # try to acquire pre-parametrized `blocking=False` lock 3 with context manager + with pytest.raises(Timeout, match="The file lock '.*' could not be acquired."), lock_3: + pass + assert not lock_3.is_locked + assert lock_1.is_locked + + # try to acquire pre-parametrized `timeout=0` lock 4 with `acquire` + with pytest.raises(Timeout, match="The file lock '.*' could not be acquired."): + lock_4.acquire() + assert not lock_4.is_locked + assert lock_1.is_locked + + # try to acquire pre-parametrized `timeout=0` lock 4 with context manager + with pytest.raises(Timeout, match="The file lock '.*' could not be acquired."), lock_4: + pass + assert not lock_4.is_locked + assert lock_1.is_locked + + # blocking precedence over timeout + # try to acquire pre-parametrized `timeout=-1,blocking=False` lock 5 with `acquire` + with pytest.raises(Timeout, match="The file lock '.*' could not be acquired."): + lock_5.acquire() + assert not lock_5.is_locked + assert lock_1.is_locked + + # try to acquire pre-parametrized `timeout=-1,blocking=False` lock 5 with context manager + with pytest.raises(Timeout, match="The file lock '.*' could not be acquired."), lock_5: + pass + assert not lock_5.is_locked + assert lock_1.is_locked + # release lock 1 lock_1.release() assert not lock_1.is_locked assert not lock_2.is_locked + assert not lock_3.is_locked + assert not lock_4.is_locked + assert not lock_5.is_locked @pytest.mark.parametrize("lock_type", [FileLock, SoftFileLock])
participants (1)
-
Source-Sync