[Python-modules-commits] [flufl.lock] 01/10: Import flufl.lock_3.2.orig.tar.gz

Pierre-Elliott Bécue peb-guest at moszumanska.debian.org
Sat Nov 25 16:40:16 UTC 2017


This is an automated email from the git hooks/post-receive script.

peb-guest pushed a commit to branch master
in repository flufl.lock.

commit 7df29346f3fb7343e232c07e170822c279cac4b2
Author: Pierre-Elliott Bécue <becue at crans.org>
Date:   Sat Nov 25 16:50:10 2017 +0100

    Import flufl.lock_3.2.orig.tar.gz
---
 .coverage.ini                          |  18 +++++
 PKG-INFO                               | 137 ++-------------------------------
 README.rst                             |  17 ++--
 flufl.lock.egg-info/PKG-INFO           | 137 ++-------------------------------
 flufl.lock.egg-info/SOURCES.txt        |   7 +-
 flufl.lock.egg-info/requires.txt       |   1 +
 flufl/__init__.py                      |  24 +-----
 flufl/lock/NEWS.rst                    |  81 +++++++++++--------
 flufl/lock/README.rst                  |  29 ++-----
 flufl/lock/__init__.py                 |  44 ++++-------
 flufl/lock/_lockfile.py                | 134 +++++++++++++++-----------------
 flufl/lock/conf.py                     |   2 +-
 flufl/lock/docs/using.rst              |  67 +++++++++++-----
 flufl/lock/testing/__init__.py         |   0
 flufl/lock/testing/helpers.py          | 111 ++++++++++++++++++++++++++
 flufl/lock/tests/subproc.py            |  68 ----------------
 flufl/lock/tests/test_documentation.py | 133 --------------------------------
 flufl/lock/tests/test_lockfile.py      |  91 ++++++++--------------
 setup.py                               |  36 ++-------
 template.py                            |  23 ------
 tox.ini                                |  56 +++++++++++++-
 21 files changed, 425 insertions(+), 791 deletions(-)

diff --git a/.coverage.ini b/.coverage.ini
new file mode 100644
index 0000000..2d910eb
--- /dev/null
+++ b/.coverage.ini
@@ -0,0 +1,18 @@
+[run]
+branch = true
+parallel = true
+omit =
+     setup*
+     flufl/lock/testing/*
+     flufl/lock/tests/*
+    .tox/*/lib/python3.*/site-packages/*
+
+[paths]
+source =
+    flufl/lock
+    .tox/*/lib/python*/site-packages/flufl/lock
+
+[report]
+exclude_lines =
+    pragma: nocover
+    pragma: no${PLATFORM}
diff --git a/PKG-INFO b/PKG-INFO
index 38fa3e5..e248256 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,147 +1,20 @@
 Metadata-Version: 1.1
 Name: flufl.lock
-Version: 2.4.1
+Version: 3.2
 Summary: NFS-safe file locking with timeouts for POSIX systems.
-Home-page: http://launchpad.net/flufl.lock
+Home-page: https://flufllock.readthedocs.io
 Author: Barry Warsaw
 Author-email: barry at python.org
-License: LGPLv3
+License: ASLv2
 Download-URL: https://pypi.python.org/pypi/flufl.lock
-Description:    ==========
-           flufl.lock
-           ==========
-           
-           NFS-safe file locking with timeouts for POSIX systems.
-           
-           The `flufl.lock` library provides an NFS-safe file-based locking algorithm
-           influenced by the GNU/Linux `open(2)` manpage, under the description of the
-           `O_EXCL` option.
-           
-               [...] O_EXCL is broken on NFS file systems, programs which rely on it
-               for performing locking tasks will contain a race condition.  The
-               solution for performing atomic file locking using a lockfile is to
-               create a unique file on the same fs (e.g., incorporating hostname and
-               pid), use link(2) to make a link to the lockfile.  If link() returns
-               0, the lock is successful.  Otherwise, use stat(2) on the unique file
-               to check if its link count has increased to 2, in which case the lock
-               is also successful.
-           
-           The assumption made here is that there will be no *outside interference*,
-           e.g. no agent external to this code will ever `link()` to the specific lock
-           files used.
-           
-           Lock objects support lock-breaking so that you can't wedge a process forever.
-           This is especially helpful in a web environment, but may not be appropriate
-           for all applications.
-           
-           Locks have a *lifetime*, which is the maximum length of time the process
-           expects to retain the lock.  It is important to pick a good number here
-           because other processes will not break an existing lock until the expected
-           lifetime has expired.  Too long and other processes will hang; too short and
-           you'll end up trampling on existing process locks -- and possibly corrupting
-           data.  In a distributed (NFS) environment, you also need to make sure that
-           your clocks are properly synchronized.
-           
-           
-           Author
-           ======
-           
-           `flufl.lock` is Copyright (C) 2007-2015 Barry Warsaw <barry at python.org>
-           
-           Licensed under the terms of the GNU Lesser General Public License, version 3
-           or later.  See the COPYING.LESSER file for details.
-           
-           
-           Project details
-           ===============
-           
-            * Project home: https://gitlab.com/warsaw/flufl.lock
-            * Report bugs at: https://gitlab.com/warsaw/flufl.lock/issues
-            * Code hosting: git at gitlab.com:warsaw/flufl.lock.git
-            * Documentation: http://flufllock.readthedocs.org/
-        
-           ===================
-           NEWS for flufl.lock
-           ===================
-           
-           2.4.1 (2015-10-29)
-           ==================
-            * Fix the MANIFEST.in so that tox.ini is included in the sdist.
-           
-           2.4 (2015-10-10)
-           ================
-            * Drop Python 2.6 compatibility.
-            * Add Python 3.5 compatibility.
-           
-           2.3.1 (2014-09-26)
-           ==================
-            * Include MANIFEST.in in the sdist tarball, otherwise the Debian package
-              won't built correctly.
-           
-           2.3 (2014-09-25)
-           ================
-            * Fix documentation bug.  (LP: #1026403)
-            * Catch ESTALE along with ENOENT, as NFS servers are supposed to (but don't
-              always) throw ESTALE instead of ENOENT.  (LP: #977999)
-            * Purge all references to `distribute`.  (LP: #1263794)
-           
-           2.2.1 (2012-04-19)
-           ==================
-            * Add classifiers to setup.py and make the long description more compatible
-              with the Cheeseshop.
-            * Other changes to make the Cheeseshop page look nicer.  (LP: #680136)
-            * setup_helper.py version 2.1.
-           
-           2.2 (2012-01-19)
-           ================
-            * Support Python 3 without the use of 2to3.
-            * Make the documentation clear that the `flufl.test.subproc` functions are
-              not part of the public API.  (LP: #838338)
-            * Fix claim file format in `take_possession()`.  (LP: #872096)
-            * Provide a new API for dealing with possible additional unexpected errnos
-              while trying to read the lock file.  These can happen in some NFS
-              environments.  If you want to retry the read, set the lock file's
-              `retry_errnos` property to a sequence of errnos.  If one of those errnos
-              occurs, the read is unconditionally (and infinitely) retried.
-              `retry_errnos` is a property which must be set to a sequence; it has a
-              getter and a deleter too.  (LP: #882261)
-           
-           2.1.1 (2011-08-20)
-           ==================
-            * Fixed TypeError in .lock() method due to race condition in _releasetime
-              property.  Found by Stephen A. Goss. (LP: #827052)
-           
-           2.1 (2010-12-22)
-           ================
-            * Added lock.details.
-           
-           2.0.2 (2010-12-19)
-           ==================
-            * Small adjustment to doctest.
-           
-           2.0.1 (2010-11-27)
-           ==================
-            * Add missing exception to __all__.
-           
-           2.0 (2010-11-26)
-           ================
-            * Package renamed to flufl.lock.
-           
-           Earlier
-           =======
-           
-           Try `bzr log lp:flufl.lock` for details.
-        
-        
+Description: UNKNOWN
 Platform: UNKNOWN
 Classifier: Development Status :: 5 - Production/Stable
 Classifier: Intended Audience :: Developers
-Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)
+Classifier: License :: OSI Approved :: Apache Software License
 Classifier: Operating System :: POSIX
 Classifier: Operating System :: MacOS :: MacOS X
 Classifier: Programming Language :: Python
-Classifier: Programming Language :: Python :: 2.6
-Classifier: Programming Language :: Python :: 2.7
 Classifier: Programming Language :: Python :: 3
 Classifier: Topic :: Software Development :: Libraries
 Classifier: Topic :: Software Development :: Libraries :: Python Modules
diff --git a/README.rst b/README.rst
index dcca0f5..3366e55 100644
--- a/README.rst
+++ b/README.rst
@@ -4,9 +4,9 @@ flufl.lock
 
 NFS-safe file locking with timeouts for POSIX systems.
 
-The `flufl.lock` library provides an NFS-safe file-based locking algorithm
-influenced by the GNU/Linux `open(2)` manpage, under the description of the
-`O_EXCL` option.
+The ``flufl.lock`` library provides an NFS-safe file-based locking algorithm
+influenced by the GNU/Linux ``open(2)`` manpage, under the description of the
+``O_EXCL`` option.
 
     [...] O_EXCL is broken on NFS file systems, programs which rely on it
     for performing locking tasks will contain a race condition.  The
@@ -18,7 +18,7 @@ influenced by the GNU/Linux `open(2)` manpage, under the description of the
     is also successful.
 
 The assumption made here is that there will be no *outside interference*,
-e.g. no agent external to this code will ever `link()` to the specific lock
+e.g. no agent external to this code will ever ``link()`` to the specific lock
 files used.
 
 Lock objects support lock-breaking so that you can't wedge a process forever.
@@ -37,10 +37,7 @@ your clocks are properly synchronized.
 Author
 ======
 
-`flufl.lock` is Copyright (C) 2007-2015 Barry Warsaw <barry at python.org>
-
-Licensed under the terms of the GNU Lesser General Public License, version 3
-or later.  See the COPYING.LESSER file for details.
+``flufl.lock`` is Copyright (C) 2007-2017 Barry Warsaw <barry at python.org>
 
 
 Project details
@@ -48,5 +45,5 @@ Project details
 
  * Project home: https://gitlab.com/warsaw/flufl.lock
  * Report bugs at: https://gitlab.com/warsaw/flufl.lock/issues
- * Code hosting: git at gitlab.com:warsaw/flufl.lock.git
- * Documentation: http://flufllock.readthedocs.org/
+ * Code hosting: https://gitlab.com/warsaw/flufl.lock.git
+ * Documentation: http://flufllock.readthedocs.io/
diff --git a/flufl.lock.egg-info/PKG-INFO b/flufl.lock.egg-info/PKG-INFO
index 38fa3e5..e248256 100644
--- a/flufl.lock.egg-info/PKG-INFO
+++ b/flufl.lock.egg-info/PKG-INFO
@@ -1,147 +1,20 @@
 Metadata-Version: 1.1
 Name: flufl.lock
-Version: 2.4.1
+Version: 3.2
 Summary: NFS-safe file locking with timeouts for POSIX systems.
-Home-page: http://launchpad.net/flufl.lock
+Home-page: https://flufllock.readthedocs.io
 Author: Barry Warsaw
 Author-email: barry at python.org
-License: LGPLv3
+License: ASLv2
 Download-URL: https://pypi.python.org/pypi/flufl.lock
-Description:    ==========
-           flufl.lock
-           ==========
-           
-           NFS-safe file locking with timeouts for POSIX systems.
-           
-           The `flufl.lock` library provides an NFS-safe file-based locking algorithm
-           influenced by the GNU/Linux `open(2)` manpage, under the description of the
-           `O_EXCL` option.
-           
-               [...] O_EXCL is broken on NFS file systems, programs which rely on it
-               for performing locking tasks will contain a race condition.  The
-               solution for performing atomic file locking using a lockfile is to
-               create a unique file on the same fs (e.g., incorporating hostname and
-               pid), use link(2) to make a link to the lockfile.  If link() returns
-               0, the lock is successful.  Otherwise, use stat(2) on the unique file
-               to check if its link count has increased to 2, in which case the lock
-               is also successful.
-           
-           The assumption made here is that there will be no *outside interference*,
-           e.g. no agent external to this code will ever `link()` to the specific lock
-           files used.
-           
-           Lock objects support lock-breaking so that you can't wedge a process forever.
-           This is especially helpful in a web environment, but may not be appropriate
-           for all applications.
-           
-           Locks have a *lifetime*, which is the maximum length of time the process
-           expects to retain the lock.  It is important to pick a good number here
-           because other processes will not break an existing lock until the expected
-           lifetime has expired.  Too long and other processes will hang; too short and
-           you'll end up trampling on existing process locks -- and possibly corrupting
-           data.  In a distributed (NFS) environment, you also need to make sure that
-           your clocks are properly synchronized.
-           
-           
-           Author
-           ======
-           
-           `flufl.lock` is Copyright (C) 2007-2015 Barry Warsaw <barry at python.org>
-           
-           Licensed under the terms of the GNU Lesser General Public License, version 3
-           or later.  See the COPYING.LESSER file for details.
-           
-           
-           Project details
-           ===============
-           
-            * Project home: https://gitlab.com/warsaw/flufl.lock
-            * Report bugs at: https://gitlab.com/warsaw/flufl.lock/issues
-            * Code hosting: git at gitlab.com:warsaw/flufl.lock.git
-            * Documentation: http://flufllock.readthedocs.org/
-        
-           ===================
-           NEWS for flufl.lock
-           ===================
-           
-           2.4.1 (2015-10-29)
-           ==================
-            * Fix the MANIFEST.in so that tox.ini is included in the sdist.
-           
-           2.4 (2015-10-10)
-           ================
-            * Drop Python 2.6 compatibility.
-            * Add Python 3.5 compatibility.
-           
-           2.3.1 (2014-09-26)
-           ==================
-            * Include MANIFEST.in in the sdist tarball, otherwise the Debian package
-              won't built correctly.
-           
-           2.3 (2014-09-25)
-           ================
-            * Fix documentation bug.  (LP: #1026403)
-            * Catch ESTALE along with ENOENT, as NFS servers are supposed to (but don't
-              always) throw ESTALE instead of ENOENT.  (LP: #977999)
-            * Purge all references to `distribute`.  (LP: #1263794)
-           
-           2.2.1 (2012-04-19)
-           ==================
-            * Add classifiers to setup.py and make the long description more compatible
-              with the Cheeseshop.
-            * Other changes to make the Cheeseshop page look nicer.  (LP: #680136)
-            * setup_helper.py version 2.1.
-           
-           2.2 (2012-01-19)
-           ================
-            * Support Python 3 without the use of 2to3.
-            * Make the documentation clear that the `flufl.test.subproc` functions are
-              not part of the public API.  (LP: #838338)
-            * Fix claim file format in `take_possession()`.  (LP: #872096)
-            * Provide a new API for dealing with possible additional unexpected errnos
-              while trying to read the lock file.  These can happen in some NFS
-              environments.  If you want to retry the read, set the lock file's
-              `retry_errnos` property to a sequence of errnos.  If one of those errnos
-              occurs, the read is unconditionally (and infinitely) retried.
-              `retry_errnos` is a property which must be set to a sequence; it has a
-              getter and a deleter too.  (LP: #882261)
-           
-           2.1.1 (2011-08-20)
-           ==================
-            * Fixed TypeError in .lock() method due to race condition in _releasetime
-              property.  Found by Stephen A. Goss. (LP: #827052)
-           
-           2.1 (2010-12-22)
-           ================
-            * Added lock.details.
-           
-           2.0.2 (2010-12-19)
-           ==================
-            * Small adjustment to doctest.
-           
-           2.0.1 (2010-11-27)
-           ==================
-            * Add missing exception to __all__.
-           
-           2.0 (2010-11-26)
-           ================
-            * Package renamed to flufl.lock.
-           
-           Earlier
-           =======
-           
-           Try `bzr log lp:flufl.lock` for details.
-        
-        
+Description: UNKNOWN
 Platform: UNKNOWN
 Classifier: Development Status :: 5 - Production/Stable
 Classifier: Intended Audience :: Developers
-Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)
+Classifier: License :: OSI Approved :: Apache Software License
 Classifier: Operating System :: POSIX
 Classifier: Operating System :: MacOS :: MacOS X
 Classifier: Programming Language :: Python
-Classifier: Programming Language :: Python :: 2.6
-Classifier: Programming Language :: Python :: 2.7
 Classifier: Programming Language :: Python :: 3
 Classifier: Topic :: Software Development :: Libraries
 Classifier: Topic :: Software Development :: Libraries :: Python Modules
diff --git a/flufl.lock.egg-info/SOURCES.txt b/flufl.lock.egg-info/SOURCES.txt
index ce5b4e6..f5884f2 100644
--- a/flufl.lock.egg-info/SOURCES.txt
+++ b/flufl.lock.egg-info/SOURCES.txt
@@ -1,15 +1,16 @@
+.coverage.ini
 MANIFEST.in
 README.rst
 setup.cfg
 setup.py
 setup_helpers.py
-template.py
 tox.ini
 flufl/__init__.py
 flufl.lock.egg-info/PKG-INFO
 flufl.lock.egg-info/SOURCES.txt
 flufl.lock.egg-info/dependency_links.txt
 flufl.lock.egg-info/namespace_packages.txt
+flufl.lock.egg-info/requires.txt
 flufl.lock.egg-info/top_level.txt
 flufl/lock/NEWS.rst
 flufl/lock/README.rst
@@ -18,7 +19,7 @@ flufl/lock/_lockfile.py
 flufl/lock/conf.py
 flufl/lock/docs/__init__.py
 flufl/lock/docs/using.rst
+flufl/lock/testing/__init__.py
+flufl/lock/testing/helpers.py
 flufl/lock/tests/__init__.py
-flufl/lock/tests/subproc.py
-flufl/lock/tests/test_documentation.py
 flufl/lock/tests/test_lockfile.py
\ No newline at end of file
diff --git a/flufl.lock.egg-info/requires.txt b/flufl.lock.egg-info/requires.txt
new file mode 100644
index 0000000..4cd98b3
--- /dev/null
+++ b/flufl.lock.egg-info/requires.txt
@@ -0,0 +1 @@
+atpublic
diff --git a/flufl/__init__.py b/flufl/__init__.py
index ecb8ba2..de40ea7 100644
--- a/flufl/__init__.py
+++ b/flufl/__init__.py
@@ -1,23 +1 @@
-# Copyright (C) 2004-2015 Barry A. Warsaw
-#
-# This file is part of flufl.lock.
-#
-# flufl.lock is free software: you can redistribute it and/or modify it
-# under the terms of the GNU Lesser General Public License as published by
-# the Free Software Foundation, version 3 of the License.
-#
-# flufl.lock is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
-# License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with flufl.lock.  If not, see <http://www.gnu.org/licenses/>.
-
-# this is a namespace package
-try:
-    import pkg_resources
-    pkg_resources.declare_namespace(__name__)
-except ImportError:
-    import pkgutil
-    __path__ = pkgutil.extend_path(__path__, __name__)
+__import__('pkg_resources').declare_namespace(__name__)
diff --git a/flufl/lock/NEWS.rst b/flufl/lock/NEWS.rst
index acb5171..4ec4bc8 100644
--- a/flufl/lock/NEWS.rst
+++ b/flufl/lock/NEWS.rst
@@ -2,70 +2,89 @@
 NEWS for flufl.lock
 ===================
 
+3.2 (2017-09-03)
+================
+* Expose the host name used in the ``.details`` property, as a property.
+  (Closes #4).
+
+3.1 (2017-07-15)
+================
+* Expose the ``SEP`` as a public attribute.  (Closes #3)
+
+3.0 (2017-05-31)
+================
+* Drop Python 2.7, add Python 3.6.  (Closes #2)
+* Added Windows support.
+* Switch to the Apache License Version 2.0.
+* Use flufl.testing for nose2 and flake8 plugins.
+* Allow the claim file separator to be configurable, to support file systems
+  where the vertical bar is problematic.  Defaults to ``^`` on Windows and
+  ``|`` everywhere else (unchanged).  (Closes #1)
+
 2.4.1 (2015-10-29)
 ==================
- * Fix the MANIFEST.in so that tox.ini is included in the sdist.
+* Fix the MANIFEST.in so that tox.ini is included in the sdist.
 
 2.4 (2015-10-10)
 ================
- * Drop Python 2.6 compatibility.
- * Add Python 3.5 compatibility.
+* Drop Python 2.6 compatibility.
+* Add Python 3.5 compatibility.
 
 2.3.1 (2014-09-26)
 ==================
- * Include MANIFEST.in in the sdist tarball, otherwise the Debian package
-   won't built correctly.
+* Include MANIFEST.in in the sdist tarball, otherwise the Debian package
+  won't built correctly.
 
 2.3 (2014-09-25)
 ================
- * Fix documentation bug.  (LP: #1026403)
- * Catch ESTALE along with ENOENT, as NFS servers are supposed to (but don't
-   always) throw ESTALE instead of ENOENT.  (LP: #977999)
- * Purge all references to `distribute`.  (LP: #1263794)
+* Fix documentation bug.  (LP: #1026403)
+* Catch ESTALE along with ENOENT, as NFS servers are supposed to (but don't
+  always) throw ESTALE instead of ENOENT.  (LP: #977999)
+* Purge all references to ``distribute``.  (LP: #1263794)
 
 2.2.1 (2012-04-19)
 ==================
- * Add classifiers to setup.py and make the long description more compatible
-   with the Cheeseshop.
- * Other changes to make the Cheeseshop page look nicer.  (LP: #680136)
- * setup_helper.py version 2.1.
+* Add classifiers to setup.py and make the long description more compatible
+  with the Cheeseshop.
+* Other changes to make the Cheeseshop page look nicer.  (LP: #680136)
+* setup_helper.py version 2.1.
 
 2.2 (2012-01-19)
 ================
- * Support Python 3 without the use of 2to3.
- * Make the documentation clear that the `flufl.test.subproc` functions are
-   not part of the public API.  (LP: #838338)
- * Fix claim file format in `take_possession()`.  (LP: #872096)
- * Provide a new API for dealing with possible additional unexpected errnos
-   while trying to read the lock file.  These can happen in some NFS
-   environments.  If you want to retry the read, set the lock file's
-   `retry_errnos` property to a sequence of errnos.  If one of those errnos
-   occurs, the read is unconditionally (and infinitely) retried.
-   `retry_errnos` is a property which must be set to a sequence; it has a
-   getter and a deleter too.  (LP: #882261)
+* Support Python 3 without the use of 2to3.
+* Make the documentation clear that the ``flufl.test.subproc`` functions are
+  not part of the public API.  (LP: #838338)
+* Fix claim file format in ``take_possession()``.  (LP: #872096)
+* Provide a new API for dealing with possible additional unexpected errnos
+  while trying to read the lock file.  These can happen in some NFS
+  environments.  If you want to retry the read, set the lock file's
+  ``retry_errnos`` property to a sequence of errnos.  If one of those errnos
+  occurs, the read is unconditionally (and infinitely) retried.
+  ``retry_errnos`` is a property which must be set to a sequence; it has a
+  getter and a deleter too.  (LP: #882261)
 
 2.1.1 (2011-08-20)
 ==================
- * Fixed TypeError in .lock() method due to race condition in _releasetime
-   property.  Found by Stephen A. Goss. (LP: #827052)
+* Fixed TypeError in .lock() method due to race condition in _releasetime
+  property.  Found by Stephen A. Goss. (LP: #827052)
 
 2.1 (2010-12-22)
 ================
- * Added lock.details.
+* Added lock.details.
 
 2.0.2 (2010-12-19)
 ==================
- * Small adjustment to doctest.
+* Small adjustment to doctest.
 
 2.0.1 (2010-11-27)
 ==================
- * Add missing exception to __all__.
+* Add missing exception to __all__.
 
 2.0 (2010-11-26)
 ================
- * Package renamed to flufl.lock.
+* Package renamed to flufl.lock.
 
 Earlier
 =======
 
-Try `bzr log lp:flufl.lock` for details.
+Try ``bzr log lp:flufl.lock`` for details.
diff --git a/flufl/lock/README.rst b/flufl/lock/README.rst
index 0821c20..1efcde5 100644
--- a/flufl/lock/README.rst
+++ b/flufl/lock/README.rst
@@ -9,14 +9,13 @@ timeouts for POSIX systems.
 Requirements
 ============
 
-``flufl.lock`` requires Python 2.6 or newer, and is compatible with Python 3.
+``flufl.lock`` requires Python 3.4 or newer.
 
 
 Documentation
 =============
 
-A `simple guide`_ to using the library is available within this package, in
-the form of doctests.
+A `simple guide`_ to using the library is available.
 
 
 Project details
@@ -24,8 +23,8 @@ Project details
 
  * Project home: https://gitlab.com/warsaw/flufl.lock
  * Report bugs at: https://gitlab.com/warsaw/flufl.lock/issues
- * Code hosting: git at gitlab.com:warsaw/flufl.lock.git
- * Documentation: http://flufllock.readthedocs.org/
+ * Code hosting: https://gitlab.com/warsaw/flufl.lock.git
+ * Documentation: http://flufllock.readthedocs.io/
 
 You can install it with ``pip``::
 
@@ -35,30 +34,16 @@ You can grab the latest development copy of the code using git.  The master
 repository is hosted on GitLab.  If you have git installed, you can grab
 your own branch of the code like this::
 
-    $ git clone git at gitlab.com:warsaw/flufl.lock.git
+    $ git clone https://gitlab.com/warsaw/flufl.lock.git
 
-You may contact the author via barry at python.org.
+You can contact the author via barry at python.org.
 
 
 Copyright
 =========
 
-Copyright (C) 2004-2015 Barry A. Warsaw
+Copyright (C) 2004-2017 Barry A. Warsaw
 
-This file is part of flufl.lock.
-
-flufl.lock is free software: you can redistribute it and/or modify it under
-the terms of the GNU Lesser General Public License as published by the Free
-Software Foundation, either version 3 of the License, or (at your option) any
-later version.
-
-flufl.lock is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
-details.
-
-You should have received a copy of the GNU Lesser General Public License along
-with flufl.lock.  If not, see <http://www.gnu.org/licenses/>.
 
 
 Table of Contents
diff --git a/flufl/lock/__init__.py b/flufl/lock/__init__.py
index fee39bf..b6c7e5b 100644
--- a/flufl/lock/__init__.py
+++ b/flufl/lock/__init__.py
@@ -1,37 +1,19 @@
-# Copyright (C) 2004-2015 Barry A. Warsaw
-#
-# This file is part of flufl.lock
-#
-# flufl.lock is free software: you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation, version 3 of the License.
-#
-# flufl.lock is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
-# for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with flufl.lock.  If not, see <http://www.gnu.org/licenses/>.
-
 """Package init."""
 
-from __future__ import absolute_import, print_function, unicode_literals
-
-__metaclass__ = type
-__all__ = [
-    'AlreadyLockedError',
-    'Lock',
-    'LockError',
-    'NotLockedError',
-    'TimeOutError',
-    '__version__',
-    ]
+from flufl.lock._lockfile import (
+    AlreadyLockedError, Lock, LockError, NotLockedError, SEP, TimeOutError)
+from public import public
 
 
-__version__ = '2.4.1'
+__version__ = '3.2'
 
 
-# Public API.
-from flufl.lock._lockfile import (
-    AlreadyLockedError, Lock, LockError, NotLockedError, TimeOutError)
+public(
+    AlreadyLockedError=AlreadyLockedError,
+    Lock=Lock,
+    LockError=LockError,
+    NotLockedError=NotLockedError,
+    SEP=SEP,
+    TimeOutError=TimeOutError,
+    __version__=__version__,
+    )
diff --git a/flufl/lock/_lockfile.py b/flufl/lock/_lockfile.py
index fe59772..f6fb7b0 100644
--- a/flufl/lock/_lockfile.py
+++ b/flufl/lock/_lockfile.py
@@ -1,20 +1,3 @@
-# Copyright (C) 2007-2015 Barry A. Warsaw
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-# USA.
-
 """Portable, NFS-safe file locking with timeouts for POSIX systems.
 
 This code implements an NFS-safe file-based locking algorithm influenced by
@@ -46,17 +29,6 @@ data.  In a distributed (NFS) environment, you also need to make sure that
 your clocks are properly synchronized.
 """
 
-from __future__ import absolute_import, print_function, unicode_literals
-
-__metaclass__ = type
-__all__ = [
-    'LockError',
-    'AlreadyLockedError',
-    'NotLockedError',
-    'Lock',
-    ]
-
-
 import os
 import sys
 import time
@@ -66,18 +38,20 @@ import socket
 import logging
 import datetime
 
-DEFAULT_LOCK_LIFETIME  = datetime.timedelta(seconds=15)
+from logging import NullHandler
+from public import public
+
+
+DEFAULT_LOCK_LIFETIME = datetime.timedelta(seconds=15)
 # Allowable a bit of clock skew.
 CLOCK_SLOP = datetime.timedelta(seconds=10)
-try:
-    MAXINT = sys.maxint
-except AttributeError:
-    # Python 3.
-    MAXINT = sys.maxsize
+MAXINT = sys.maxsize
 
 # Details separator; also used in calculating the claim file path.  Lock files
-# should not include this character.
-SEP = '|'
+# should not include this character.  We do it like this so flake8 won't
+# complain about SEP.
+SEP = ('^' if sys.platform == 'win32' else '|')
+public(SEP=SEP)
 
 # LP: #977999 - catch both ENOENT and ESTALE.  The latter is what an NFS
 # server should return, but some Linux versions return ENOENT.
@@ -88,33 +62,33 @@ log = logging.getLogger('flufl.lock')
 
 # Install a null handler to avoid warnings when applications don't set their
 # own flufl.lock logger.  See http://docs.python.org/library/logging.html
-try:
-    from logging import NullHandler
-except ImportError:
-    # Python < 2.7.
-    class NullHandler(logging.Handler):
-        def emit(self, record):
-            pass
 logging.getLogger('flufl.lock').addHandler(NullHandler())
 
 
-# Exceptions that can be raised by this module
+ at public
 class LockError(Exception):
     """Base class for all exceptions in this module."""
 
+
+ at public
 class AlreadyLockedError(LockError):
     """An attempt is made to lock an already locked object."""
 
+
+ at public
 class NotLockedError(LockError):
     """An attempt is made to unlock an object that isn't locked."""
 
+
+ at public
 class TimeOutError(LockError):
     """The timeout interval elapsed before the lock succeeded."""
 
 
+ at public
 class Lock:
     """A portable way to lock resources by way of the file system."""
-    def __init__(self, lockfile, lifetime=None):
+    def __init__(self, lockfile, lifetime=None, separator=SEP):
         """Create the resource lock using the given file name and lifetime.
 
         Each process laying claim to this resource lock will create their own
@@ -124,11 +98,18 @@ class Lock:
         :param lockfile: The full path to the lock file.
         :param lifetime: The expected maximum lifetime of the lock, as a
             timedelta.  Defaults to 15 seconds.
+        :param separator: The separator character to use in the lock file's
+            file name.  Defaults to the vertical bar (`|`) on POSIX systems
+            and caret (`^`) on Windows.
         """
+        # This has to be defined before we call _set_claimfile().
+        self._hostname = socket.getfqdn()
         if lifetime is None:
             lifetime = DEFAULT_LOCK_LIFETIME
         self._lockfile = lockfile
         self._lifetime = lifetime
+        # The separator must be set before we claim the lock.
+        self._separator = separator
         self._set_claimfile()
         # For transferring ownership across a fork.
         self._owned = True
@@ -143,6 +124,16 @@ class Lock:
             self._lifetime, os.getpid(), id(self))
 
     @property
+    def hostname(self):
+        """The current machine's host name.
+
+        :return: The current machine's hostname, as used in the `.details`
+            property.
+        :rtype: str
+        """
+        return self._hostname
+
+    @property
     def details(self):
         """Details as read from the lock file.
 
@@ -159,7 +150,8 @@ class Lock:
             raise
         # Rearrange for signature.
         try:
-            lockfile, hostname, pid, random_ignored = filename.split(SEP)
+            lockfile, hostname, pid, random_ignored = filename.split(
+                self._separator)
         except ValueError:
             raise NotLockedError('Details are unavailable')
         return hostname, int(pid), lockfile
@@ -189,7 +181,7 @@ class Lock:
             self._lifetime = lifetime
         # Do we have the lock?  As a side effect, this refreshes the lock!
         if not self.is_locked and not unconditionally:
-            raise NotLockedError('{0}: {1}'.format(repr(self), self._read()))
+            raise NotLockedError('{}: {}'.format(repr(self), self._read()))
 
     def lock(self, timeout=None):
         """Acquire the lock.
@@ -214,18 +206,18 @@ class Lock:
         # very rare occurrence, only happens from cron, and has only(?) been
         # observed on Solaris 2.6.
         self._touch()
-        log.debug('laying claim: {0}'.format(self._lockfile))
-        # For quieting the logging output
+        log.debug('laying claim: {}'.format(self._lockfile))
+        # For quieting the logging output.
         loopcount = -1
         while True:
             loopcount += 1
             # Create the hard link and test for exactly 2 links to the file.
             try:
                 os.link(self._claimfile, self._lockfile)
-                # If we got here, we know we know we got the lock, and never
+                # If we got here, we know we got the lock, and never
                 # had it before, so we're done.  Just touch it again for the
                 # fun of it.
-                log.debug('got the lock: {0}'.format(self._lockfile))
+                log.debug('got the lock: {}'.format(self._lockfile))
                 self._touch()
                 break
             except OSError as error:
@@ -255,9 +247,9 @@ class Lock:
                         self._linkcount))
                 elif self._read() == self._claimfile:
                     # It was us that already had the link.
-                    log.debug('already locked: {0}'.format(self._lockfile))
+                    log.debug('already locked: {}'.format(self._lockfile))
                     raise AlreadyLockedError('We already had the lock')
-                # otherwise, someone else has the lock
+                # Otherwise, someone else has the lock
                 pass
             # We did not acquire the lock, because someone else already has
             # it.  Have we timed out in our quest for the lock?
@@ -270,7 +262,7 @@ class Lock:
             # to avoid race conditions.  (LP: #827052)
             release_time = self._releasetime
             if (release_time != -1 and
-                datetime.datetime.now() > release_time + CLOCK_SLOP):
+                    datetime.datetime.now() > release_time + CLOCK_SLOP):
                 # Yes, so break the lock.
                 self._break()
                 log.error('lifetime has expired, breaking')
@@ -278,7 +270,7 @@ class Lock:
             # and the expected lock lifetime hasn't expired yet either.  So
             # let's wait a while for the owner of the lock to give it up.
             elif not loopcount % 100:
-                log.debug('waiting for claim: {0}'.format(self._lockfile))
+                log.debug('waiting for claim: {}'.format(self._lockfile))
             self._sleep()
 
     def unlock(self, unconditionally=False):
@@ -306,7 +298,7 @@ class Lock:
         except OSError as error:
             if error.errno not in ERRORS:
                 raise
-        log.debug('unlocked: {0}'.format(self._lockfile))
+        log.debug('unlocked: {}'.format(self._lockfile))
 
     @property
     def is_locked(self):
@@ -318,13 +310,11 @@ class Lock:
         # Discourage breaking the lock for a while.
         try:
             self._touch()
-        except OSError as error:
-            if error.errno == errno.EPERM:
-                # We can't touch the file because we're not the owner.  I
-                # don't see how we can own the lock if we're not the owner.
-                return False
-            else:
-                raise
+        except PermissionError:
+            # We can't touch the file because we're not the owner.  I don't see
+            # how we can own the lock if we're not the owner.
+            log.error('No permission to refresh the log')
+            return False
         # XXX Can the link count ever be > 2?
         if self._linkcount != 2:
             return False
@@ -332,15 +322,14 @@ class Lock:
 
     def finalize(self):
         """Unconditionally unlock the file."""
-        log.debug('finalize: {0}'.format(self._lockfile))
+        log.debug('finalize: {}'.format(self._lockfile))
         self.unlock(unconditionally=True)
 
     def __del__(self):
-        log.debug('__del__: {0}'.format(self._lockfile))
+        log.debug('__del__: {}'.format(self._lockfile))
         if self._owned:
             self.finalize()
 
-    # Python 2.5 context manager protocol support.
     def __enter__(self):
         self.lock()
         return self
@@ -386,7 +375,7 @@ class Lock:
             'Unexpected link count: wanted 2, got {0:d}'.format(
                 self._linkcount))
... 797 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/flufl.lock.git



More information about the Python-modules-commits mailing list