Mailinglist Archive: opensuse-commit (1903 mails)

< Previous Next >
commit python-zc.lockfile for openSUSE:Factory
Hello community,

here is the log from the commit of package python-zc.lockfile for
openSUSE:Factory checked in at 2019-04-19 18:36:14
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-zc.lockfile (Old)
and /work/SRC/openSUSE:Factory/.python-zc.lockfile.new.5536 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-zc.lockfile"

Fri Apr 19 18:36:14 2019 rev:5 rq:693255 version:1.4

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-zc.lockfile/python-zc.lockfile.changes
2017-07-08 12:34:56.301893024 +0200
+++
/work/SRC/openSUSE:Factory/.python-zc.lockfile.new.5536/python-zc.lockfile.changes
2019-04-19 18:36:15.487022777 +0200
@@ -1,0 +2,9 @@
+Tue Apr 9 11:06:01 UTC 2019 - Marketa Calabkova <mcalabkova@xxxxxxxx>
+
+- update to version 1.4
+ * Claim support for Python 3.4, 3.5, 3.6 and 3.7.
+ * Drop Python 2.6, 3.2 and 3.3.
+ * Stop logging failure to acquire locks. Clients can do that if
+ they wish.
+
+-------------------------------------------------------------------

Old:
----
zc.lockfile-1.2.1.tar.gz

New:
----
zc.lockfile-1.4.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-zc.lockfile.spec ++++++
--- /var/tmp/diff_new_pack.a4exkv/_old 2019-04-19 18:36:16.127023590 +0200
+++ /var/tmp/diff_new_pack.a4exkv/_new 2019-04-19 18:36:16.131023595 +0200
@@ -1,7 +1,7 @@
#
# spec file for package python-zc.lockfile
#
-# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2013 LISA GmbH, Bingen, Germany.
#
# All modifications and additions to the file contributed by third parties
@@ -13,28 +13,26 @@
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

-# Please submit bugfixes or comments via http://bugs.opensuse.org/
+# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name: python-zc.lockfile
-Version: 1.2.1
+Version: 1.4
Release: 0
Summary: Basic inter-process locks
License: ZPL-2.1
Group: Development/Libraries/Python
-Url: https://pypi.python.org/pypi/zc.lockfile
+URL: https://pypi.python.org/pypi/zc.lockfile
Source:
https://files.pythonhosted.org/packages/source/z/zc.lockfile/zc.lockfile-%{version}.tar.gz
+BuildRequires: %{python_module mock}
BuildRequires: %{python_module setuptools}
+BuildRequires: %{python_module zope.testing}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
-# Testing requirements:
-BuildRequires: %{python_module mock}
-BuildRequires: %{python_module zope.testing}
Provides: python-zc-lockfile = %{version}
Obsoletes: python-zc-lockfile < %{version}
-BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildArch: noarch
%python_subpackages

@@ -60,14 +58,14 @@
# concatenate both README.txt
cat %{buildroot}%{python_sitelib}/zc/lockfile/README.txt >> README.txt
rm %{buildroot}%{python_sitelib}/zc/lockfile/README.txt
-%python_expand %fdupes -s %{buildroot}%{$python_sitelib}
+%python_expand %fdupes %{buildroot}%{$python_sitelib}

%check
%python_exec setup.py test

%files %{python_files}
-%defattr(-,root,root)
-%doc CHANGES.txt COPYRIGHT.txt LICENSE.txt README.txt
+%license LICENSE.txt
+%doc CHANGES.rst COPYRIGHT.txt README.txt
%{python_sitelib}/*

%changelog

++++++ zc.lockfile-1.2.1.tar.gz -> zc.lockfile-1.4.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/zc.lockfile-1.2.1/.gitignore
new/zc.lockfile-1.4/.gitignore
--- old/zc.lockfile-1.2.1/.gitignore 1970-01-01 01:00:00.000000000 +0100
+++ new/zc.lockfile-1.4/.gitignore 2018-11-12 10:59:04.000000000 +0100
@@ -0,0 +1,4 @@
+*.egg-info/
+*.pyc
+/.eggs/
+/.tox/
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/zc.lockfile-1.2.1/.travis.yml
new/zc.lockfile-1.4/.travis.yml
--- old/zc.lockfile-1.2.1/.travis.yml 1970-01-01 01:00:00.000000000 +0100
+++ new/zc.lockfile-1.4/.travis.yml 2018-11-12 10:59:04.000000000 +0100
@@ -0,0 +1,19 @@
+language: python
+python:
+ - 2.7
+ - 3.4
+ - 3.5
+ - 3.6
+ - pypy
+ - pypy3
+matrix:
+ include:
+ - python: "3.7"
+ dist: xenial
+ sudo: true
+install:
+ - pip install .
+script:
+ - python setup.py test -q
+notifications:
+ email: false
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/zc.lockfile-1.2.1/CHANGES.rst
new/zc.lockfile-1.4/CHANGES.rst
--- old/zc.lockfile-1.2.1/CHANGES.rst 1970-01-01 01:00:00.000000000 +0100
+++ new/zc.lockfile-1.4/CHANGES.rst 2018-11-12 10:59:04.000000000 +0100
@@ -0,0 +1,72 @@
+Change History
+***************
+
+1.4 (2018-11-12)
+================
+
+- Claim support for Python 3.6 and 3.7.
+
+- Drop Python 2.6 and 3.3.
+
+
+1.3.0 (2018-04-23)
+==================
+
+- Stop logging failure to acquire locks. Clients can do that if they wish.
+
+- Claim support for Python 3.4 and 3.5.
+
+- Drop Python 3.2 support because pip no longer supports it.
+
+1.2.1 (2016-06-19)
+==================
+
+- Fixed: unlocking and locking didn't work when a multiprocessing
+ process was running (and presumably other conditions).
+
+1.2.0 (2016-06-09)
+==================
+
+- Added the ability to include the hostname in the lock file content.
+
+- Code and ReST markup cosmetics.
+ [alecghica]
+
+1.1.0 (2013-02-12)
+==================
+
+- Added Trove classifiers and made setup.py zest.releaser friendly.
+
+- Added Python 3.2, 3.3 and PyPy 1.9 support.
+
+- Removed Python 2.4 and Python 2.5 support.
+
+1.0.2 (2012-12-02)
+==================
+
+- Fixed: the fix included in 1.0.1 caused multiple pids to be written
+ to the lock file
+
+1.0.1 (2012-11-30)
+==================
+
+- Fixed: when there was lock contention, the pid in the lock file was
+ lost.
+
+ Thanks to Daniel Moisset reporting the problem and providing a fix
+ with tests.
+
+- Added test extra to declare test dependency on ``zope.testing``.
+
+- Using Python's ``doctest`` module instead of depreacted
+ ``zope.testing.doctest``.
+
+1.0.0 (2008-10-18)
+==================
+
+- Fixed a small bug in error logging.
+
+1.0.0b1 (2007-07-18)
+====================
+
+- Initial release
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/zc.lockfile-1.2.1/CHANGES.txt
new/zc.lockfile-1.4/CHANGES.txt
--- old/zc.lockfile-1.2.1/CHANGES.txt 2016-06-19 18:26:16.000000000 +0200
+++ new/zc.lockfile-1.4/CHANGES.txt 1970-01-01 01:00:00.000000000 +0100
@@ -1,55 +0,0 @@
-Change History
-***************
-
-1.2.1 (2016-06-19)
-==================
-
-- Fixed: unlocking and locking didn't work when a multiprocessing
- process was running (and presumably other conditions).
-
-1.2.0 (2016-06-09)
-==================
-
-- Added the ability to include the hostname in the lock file content.
-
-- Code and ReST markup cosmetics.
- [alecghica]
-
-1.1.0 (2013-02-12)
-==================
-
-- Added Trove classifiers and made setup.py zest.releaser friendly.
-
-- Added Python 3.2, 3.3 and PyPy 1.9 support.
-
-- Removed Python 2.4 and Python 2.5 support.
-
-1.0.2 (2012-12-02)
-==================
-
-- Fixed: the fix included in 1.0.1 caused multiple pids to be written
- to the lock file
-
-1.0.1 (2012-11-30)
-==================
-
-- Fixed: when there was lock contention, the pid in the lock file was
- lost.
-
- Thanks to Daniel Moisset reporting the problem and providing a fix
- with tests.
-
-- Added test extra to declare test dependency on ``zope.testing``.
-
-- Using Python's ``doctest`` module instead of depreacted
- ``zope.testing.doctest``.
-
-1.0.0 (2008-10-18)
-==================
-
-- Fixed a small bug in error logging.
-
-1.0.0b1 (2007-07-18)
-====================
-
-- Initial release
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/zc.lockfile-1.2.1/PKG-INFO
new/zc.lockfile-1.4/PKG-INFO
--- old/zc.lockfile-1.2.1/PKG-INFO 2016-06-19 18:27:21.000000000 +0200
+++ new/zc.lockfile-1.4/PKG-INFO 2018-11-12 10:59:05.000000000 +0100
@@ -1,6 +1,6 @@
-Metadata-Version: 1.1
+Metadata-Version: 2.1
Name: zc.lockfile
-Version: 1.2.1
+Version: 1.4
Summary: Basic inter-process locks
Home-page: http://www.python.org/pypi/zc.lockfile
Author: Zope Foundation
@@ -45,9 +45,10 @@
... print("Can't lock file")
Can't lock file

+ .. We don't log failure to acquire.
+
>>> for record in handler.records: # doctest: +ELLIPSIS
... print(record.levelname+' '+record.getMessage())
- ERROR Error locking file lock; pid=...

To release the lock, use it's close method:

@@ -97,6 +98,23 @@
Change History
***************

+ 1.4 (2018-11-12)
+ ================
+
+ - Claim support for Python 3.6 and 3.7.
+
+ - Drop Python 2.6 and 3.3.
+
+
+ 1.3.0 (2018-04-23)
+ ==================
+
+ - Stop logging failure to acquire locks. Clients can do that if they
wish.
+
+ - Claim support for Python 3.4 and 3.5.
+
+ - Drop Python 3.2 support because pip no longer supports it.
+
1.2.1 (2016-06-19)
==================

@@ -150,9 +168,6 @@

- Initial release

- Download
- **********************
-
Keywords: lock
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
@@ -163,11 +178,13 @@
Classifier: Operating System :: Microsoft :: Windows
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
-Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
-Classifier: Programming Language :: Python :: 3.2
-Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3.6
+Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Software Development
+Provides-Extra: test
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/zc.lockfile-1.2.1/README.rst
new/zc.lockfile-1.4/README.rst
--- old/zc.lockfile-1.2.1/README.rst 1970-01-01 01:00:00.000000000 +0100
+++ new/zc.lockfile-1.4/README.rst 2018-11-12 10:59:04.000000000 +0100
@@ -0,0 +1,14 @@
+*************************
+Basic inter-process locks
+*************************
+
+The zc.lockfile package provides a basic portable implementation of
+interprocess locks using lock files. The purpose if not specifically
+to lock files, but to simply provide locks with an implementation
+based on file-locking primitives. Of course, these locks could be
+used to mediate access to *other* files. For example, the ZODB file
+storage implementation uses file locks to mediate access to
+file-storage database files. The database files and lock file files
+are separate files.
+
+.. contents::
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/zc.lockfile-1.2.1/README.txt
new/zc.lockfile-1.4/README.txt
--- old/zc.lockfile-1.2.1/README.txt 2016-06-09 14:48:53.000000000 +0200
+++ new/zc.lockfile-1.4/README.txt 1970-01-01 01:00:00.000000000 +0100
@@ -1,14 +0,0 @@
-*************************
-Basic inter-process locks
-*************************
-
-The zc.lockfile package provides a basic portable implementation of
-interprocess locks using lock files. The purpose if not specifically
-to lock files, but to simply provide locks with an implementation
-based on file-locking primitives. Of course, these locks could be
-used to mediate access to *other* files. For example, the ZODB file
-storage implementation uses file locks to mediate access to
-file-storage database files. The database files and lock file files
-are separate files.
-
-.. contents::
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/zc.lockfile-1.2.1/doc.txt new/zc.lockfile-1.4/doc.txt
--- old/zc.lockfile-1.2.1/doc.txt 2016-06-19 18:27:21.000000000 +0200
+++ new/zc.lockfile-1.4/doc.txt 1970-01-01 01:00:00.000000000 +0100
@@ -1,146 +0,0 @@
-*************************
-Basic inter-process locks
-*************************
-
-The zc.lockfile package provides a basic portable implementation of
-interprocess locks using lock files. The purpose if not specifically
-to lock files, but to simply provide locks with an implementation
-based on file-locking primitives. Of course, these locks could be
-used to mediate access to *other* files. For example, the ZODB file
-storage implementation uses file locks to mediate access to
-file-storage database files. The database files and lock file files
-are separate files.
-
-.. contents::
-
-Detailed Documentation
-**********************
-
-Lock file support
-=================
-
-The ZODB lock_file module provides support for creating file system
-locks. These are locks that are implemented with lock files and
-OS-provided locking facilities. To create a lock, instantiate a
-LockFile object with a file name:
-
- >>> import zc.lockfile
- >>> lock = zc.lockfile.LockFile('lock')
-
-If we try to lock the same name, we'll get a lock error:
-
- >>> import zope.testing.loggingsupport
- >>> handler = zope.testing.loggingsupport.InstalledHandler('zc.lockfile')
- >>> try:
- ... zc.lockfile.LockFile('lock')
- ... except zc.lockfile.LockError:
- ... print("Can't lock file")
- Can't lock file
-
- >>> for record in handler.records: # doctest: +ELLIPSIS
- ... print(record.levelname+' '+record.getMessage())
- ERROR Error locking file lock; pid=...
-
-To release the lock, use it's close method:
-
- >>> lock.close()
-
-The lock file is not removed. It is left behind:
-
- >>> import os
- >>> os.path.exists('lock')
- True
-
-Of course, now that we've released the lock, we can create it again:
-
- >>> lock = zc.lockfile.LockFile('lock')
- >>> lock.close()
-
-.. Cleanup
-
- >>> import os
- >>> os.remove('lock')
-
-Hostname in lock file
-=====================
-
-In a container environment (e.g. Docker), the PID is typically always
-identical even if multiple containers are running under the same operating
-system instance.
-
-Clearly, inspecting lock files doesn't then help much in debugging. To identify
-the container which created the lock file, we need information about the
-container in the lock file. Since Docker uses the container identifier or name
-as the hostname, this information can be stored in the lock file in addition to
-or instead of the PID.
-
-Use the ``content_template`` keyword argument to ``LockFile`` to specify a
-custom lock file content format:
-
- >>> lock = zc.lockfile.LockFile('lock',
content_template='{pid};{hostname}')
- >>> lock.close()
-
-If you now inspected the lock file, you would see e.g.:
-
- $ cat lock
- 123;myhostname
-
-
-Change History
-***************
-
-1.2.1 (2016-06-19)
-==================
-
-- Fixed: unlocking and locking didn't work when a multiprocessing
- process was running (and presumably other conditions).
-
-1.2.0 (2016-06-09)
-==================
-
-- Added the ability to include the hostname in the lock file content.
-
-- Code and ReST markup cosmetics.
- [alecghica]
-
-1.1.0 (2013-02-12)
-==================
-
-- Added Trove classifiers and made setup.py zest.releaser friendly.
-
-- Added Python 3.2, 3.3 and PyPy 1.9 support.
-
-- Removed Python 2.4 and Python 2.5 support.
-
-1.0.2 (2012-12-02)
-==================
-
-- Fixed: the fix included in 1.0.1 caused multiple pids to be written
- to the lock file
-
-1.0.1 (2012-11-30)
-==================
-
-- Fixed: when there was lock contention, the pid in the lock file was
- lost.
-
- Thanks to Daniel Moisset reporting the problem and providing a fix
- with tests.
-
-- Added test extra to declare test dependency on ``zope.testing``.
-
-- Using Python's ``doctest`` module instead of depreacted
- ``zope.testing.doctest``.
-
-1.0.0 (2008-10-18)
-==================
-
-- Fixed a small bug in error logging.
-
-1.0.0b1 (2007-07-18)
-====================
-
-- Initial release
-
-Download
-**********************
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/zc.lockfile-1.2.1/setup.cfg
new/zc.lockfile-1.4/setup.cfg
--- old/zc.lockfile-1.2.1/setup.cfg 2016-06-19 18:27:21.000000000 +0200
+++ new/zc.lockfile-1.4/setup.cfg 2018-11-12 10:59:05.000000000 +0100
@@ -1,5 +1,4 @@
[egg_info]
tag_build =
-tag_svn_revision = 0
tag_date = 0

diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/zc.lockfile-1.2.1/setup.py
new/zc.lockfile-1.4/setup.py
--- old/zc.lockfile-1.2.1/setup.py 2016-06-19 18:26:39.000000000 +0200
+++ new/zc.lockfile-1.4/setup.py 2018-11-12 10:59:04.000000000 +0100
@@ -12,7 +12,7 @@
#
##############################################################################

-version = '1.2.1'
+version = '1.4'

import os
from setuptools import setup, find_packages
@@ -25,21 +25,16 @@
return open(os.path.join(os.path.dirname(__file__), *rnames)).read()

long_description=(
- read('README.txt')
+ read('README.rst')
+ '\n' +
'Detailed Documentation\n'
'**********************\n'
+ '\n' +
read('src', 'zc', 'lockfile', 'README.txt')
+ '\n' +
- read('CHANGES.txt')
- + '\n' +
- 'Download\n'
- '**********************\n'
+ read('CHANGES.rst')
)

-open('doc.txt', 'w').write(long_description)
-
setup(
name = 'zc.lockfile',
version=version,
@@ -67,11 +62,12 @@
'Operating System :: Microsoft :: Windows',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
- 'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
- 'Programming Language :: Python :: 3.2',
- 'Programming Language :: Python :: 3.3',
+ 'Programming Language :: Python :: 3.4',
+ 'Programming Language :: Python :: 3.5',
+ 'Programming Language :: Python :: 3.6',
+ 'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Topic :: Software Development',
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/zc.lockfile-1.2.1/src/zc/lockfile/README.txt
new/zc.lockfile-1.4/src/zc/lockfile/README.txt
--- old/zc.lockfile-1.2.1/src/zc/lockfile/README.txt 2016-06-09
14:48:53.000000000 +0200
+++ new/zc.lockfile-1.4/src/zc/lockfile/README.txt 2018-11-12
10:59:04.000000000 +0100
@@ -19,9 +19,10 @@
... print("Can't lock file")
Can't lock file

+.. We don't log failure to acquire.
+
>>> for record in handler.records: # doctest: +ELLIPSIS
... print(record.levelname+' '+record.getMessage())
- ERROR Error locking file lock; pid=...

To release the lock, use it's close method:

diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/zc.lockfile-1.2.1/src/zc/lockfile/__init__.py
new/zc.lockfile-1.4/src/zc/lockfile/__init__.py
--- old/zc.lockfile-1.2.1/src/zc/lockfile/__init__.py 2016-06-19
18:25:46.000000000 +0200
+++ new/zc.lockfile-1.4/src/zc/lockfile/__init__.py 2018-11-12
10:59:04.000000000 +0100
@@ -87,22 +87,10 @@
try:
_lock_file(fp)
except:
- fp.seek(1)
- content = fp.read().strip()
fp.close()
- if content_template == '{pid}':
- # Original exception message format when using the default
- # lock file template
- pid = content[:20] if content else 'UNKNOWN'
- logger.exception("Error locking file %s; pid=%s", path, pid)
- else:
- # Include the first 40 characters of lock file contents for
- # custom lock file templates
- logger.exception('Error locking file %s; content: "%s%s"',
- path, content[:40],
- '...' if len(content) > 40 else '')
raise

+ # We got the lock, record info in the file.
self._fp = fp
fp.write(" %s\n" % content_template.format(pid=os.getpid(),
hostname=LazyHostName()))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/zc.lockfile-1.2.1/src/zc/lockfile/__init__.py~
new/zc.lockfile-1.4/src/zc/lockfile/__init__.py~
--- old/zc.lockfile-1.2.1/src/zc/lockfile/__init__.py~ 2016-06-09
14:48:53.000000000 +0200
+++ new/zc.lockfile-1.4/src/zc/lockfile/__init__.py~ 1970-01-01
01:00:00.000000000 +0100
@@ -1,118 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Foundation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE
-#
-##############################################################################
-
-import os
-import errno
-import logging
-logger = logging.getLogger("zc.lockfile")
-
-class LockError(Exception):
- """Couldn't get a lock
- """
-
-try:
- import fcntl
-except ImportError:
- try:
- import msvcrt
- except ImportError:
- def _lock_file(file):
- raise TypeError('No file-locking support on this platform')
- def _unlock_file(file):
- raise TypeError('No file-locking support on this platform')
-
- else:
- # Windows
- def _lock_file(file):
- # Lock just the first byte
- try:
- msvcrt.locking(file.fileno(), msvcrt.LK_NBLCK, 1)
- except IOError:
- raise LockError("Couldn't lock %r" % file.name)
-
- def _unlock_file(file):
- try:
- file.seek(0)
- msvcrt.locking(file.fileno(), msvcrt.LK_UNLCK, 1)
- except IOError:
- raise LockError("Couldn't unlock %r" % file.name)
-
-else:
- # Unix
- _flags = fcntl.LOCK_EX | fcntl.LOCK_NB
-
- def _lock_file(file):
- try:
- fcntl.flock(file.fileno(), _flags)
- except IOError:
- raise LockError("Couldn't lock %r" % file.name)
-
- def _unlock_file(file):
- # File is automatically unlocked on close
- pass
-
-
-class LazyHostName(object):
- """Avoid importing socket and calling gethostname() unnecessarily"""
- def __str__(self):
- import socket
- return socket.gethostname()
-
-
-class LockFile:
-
- _fp = None
-
- def __init__(self, path, content_template='{pid}'):
- self._path = path
- try:
- # Try to open for writing without truncation:
- fp = open(path, 'r+')
- except IOError:
- # If the file doesn't exist, we'll get an IO error, try a+
- # Note that there may be a race here. Multiple processes
- # could fail on the r+ open and open the file a+, but only
- # one will get the the lock and write a pid.
- fp = open(path, 'a+')
-
- try:
- _lock_file(fp)
- except:
- fp.seek(1)
- content = fp.read().strip()
- fp.close()
- if content_template == '{pid}':
- # Original exception message format when using the default
- # lock file template
- pid = content[:20] if content else 'UNKNOWN'
- logger.exception("Error locking file %s; pid=%s", path, pid)
- else:
- # Include the first 40 characters of lock file contents for
- # custom lock file templates
- logger.exception('Error locking file %s; content: "%s%s"',
- path, content[:40],
- '...' if len(content) > 40 else '')
- raise
-
- self._fp = fp
- fp.write(" %s\n" % content_template.format(pid=os.getpid(),
- hostname=LazyHostName()))
- fp.truncate()
- fp.flush()
-
- def close(self):
- if self._fp is not None:
- _unlock_file(self._fp)
- self._fp.close()
- self._fp = None
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/zc.lockfile-1.2.1/src/zc/lockfile/tests.py
new/zc.lockfile-1.4/src/zc/lockfile/tests.py
--- old/zc.lockfile-1.2.1/src/zc/lockfile/tests.py 2016-06-19
18:25:46.000000000 +0200
+++ new/zc.lockfile-1.4/src/zc/lockfile/tests.py 2018-11-12
10:59:04.000000000 +0100
@@ -150,40 +150,16 @@
os.chdir(self.here)
setupstack.rmtree(self.tmp)

- def test_log_entry(self):
+ def test_log_formatting(self):
# PID and hostname are parsed and logged from lock file on failure
- test_logger = TestLogger()
-
- def lock(locked, before_closing):
- lock = None
- try:
+ with patch('os.getpid', Mock(return_value=123)):
+ with patch('socket.gethostname', Mock(return_value='myhostname')):
lock = zc.lockfile.LockFile('f.lock',

content_template='{pid}/{hostname}')
- except Exception:
- pass
- locked.set()
- before_closing.wait()
- if lock is not None:
- lock.close()
+ with open('f.lock') as f:
+ self.assertEqual(' 123/myhostname\n', f.read())

- with patch('os.getpid', Mock(return_value=123)):
- with patch('socket.gethostname', Mock(return_value='myhostname')):
- with patch.object(zc.lockfile, 'logger', test_logger):
- first_locked = threading.Event()
- second_locked = threading.Event()
- thread1 = threading.Thread(
- target=lock, args=(first_locked, second_locked))
- thread2 = threading.Thread(
- target=lock, args=(second_locked, second_locked))
- thread1.start()
- first_locked.wait()
- assert not test_logger.log_entries
- thread2.start()
- thread1.join()
- thread2.join()
- expected = [('Error locking file %s; content: "%s%s"',
- 'f.lock', '123/myhostname', '')]
- assert test_logger.log_entries == expected, test_logger.log_entries
+ lock.close()

def test_unlock_and_lock_while_multiprocessing_process_running(self):
import multiprocessing
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/zc.lockfile-1.2.1/src/zc/lockfile/tests.py~
new/zc.lockfile-1.4/src/zc/lockfile/tests.py~
--- old/zc.lockfile-1.2.1/src/zc/lockfile/tests.py~ 2016-06-09
14:48:53.000000000 +0200
+++ new/zc.lockfile-1.4/src/zc/lockfile/tests.py~ 1970-01-01
01:00:00.000000000 +0100
@@ -1,199 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2004 Zope Foundation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-import os, re, sys, unittest, doctest
-import zc.lockfile, time, threading
-from zope.testing import renormalizing, setupstack
-import tempfile
-try:
- from unittest.mock import Mock, patch
-except ImportError:
- from mock import Mock, patch
-
-checker = renormalizing.RENormalizing([
- # Python 3 adds module path to error class name.
- (re.compile("zc\.lockfile\.LockError:"),
- r"LockError:"),
- ])
-
-def inc():
- while 1:
- try:
- lock = zc.lockfile.LockFile('f.lock')
- except zc.lockfile.LockError:
- continue
- else:
- break
- f = open('f', 'r+b')
- v = int(f.readline().strip())
- time.sleep(0.01)
- v += 1
- f.seek(0)
- f.write(('%d\n' % v).encode('ASCII'))
- f.close()
- lock.close()
-
-def many_threads_read_and_write():
- r"""
- >>> with open('f', 'w+b') as file:
- ... _ = file.write(b'0\n')
- >>> with open('f.lock', 'w+b') as file:
- ... _ = file.write(b'0\n')
-
- >>> n = 50
- >>> threads = [threading.Thread(target=inc) for i in range(n)]
- >>> _ = [thread.start() for thread in threads]
- >>> _ = [thread.join() for thread in threads]
- >>> with open('f', 'rb') as file:
- ... saved = int(file.read().strip())
- >>> saved == n
- True
-
- >>> os.remove('f')
-
- We should only have one pid in the lock file:
-
- >>> f = open('f.lock')
- >>> len(f.read().strip().split())
- 1
- >>> f.close()
-
- >>> os.remove('f.lock')
-
- """
-
-def pid_in_lockfile():
- r"""
- >>> import os, zc.lockfile
- >>> pid = os.getpid()
- >>> lock = zc.lockfile.LockFile("f.lock")
- >>> f = open("f.lock")
- >>> _ = f.seek(1)
- >>> f.read().strip() == str(pid)
- True
- >>> f.close()
-
- Make sure that locking twice does not overwrite the old pid:
-
- >>> lock = zc.lockfile.LockFile("f.lock")
- Traceback (most recent call last):
- ...
- LockError: Couldn't lock 'f.lock'
-
- >>> f = open("f.lock")
- >>> _ = f.seek(1)
- >>> f.read().strip() == str(pid)
- True
- >>> f.close()
-
- >>> lock.close()
- """
-
-
-def hostname_in_lockfile():
- r"""
- hostname is correctly written into the lock file when it's included in the
- lock file content template
-
- >>> import zc.lockfile
- >>> with patch('socket.gethostname', Mock(return_value='myhostname')):
- ... lock = zc.lockfile.LockFile("f.lock",
content_template='{hostname}')
- >>> f = open("f.lock")
- >>> _ = f.seek(1)
- >>> f.read().rstrip()
- 'myhostname'
- >>> f.close()
-
- Make sure that locking twice does not overwrite the old hostname:
-
- >>> lock = zc.lockfile.LockFile("f.lock", content_template='{hostname}')
- Traceback (most recent call last):
- ...
- LockError: Couldn't lock 'f.lock'
-
- >>> f = open("f.lock")
- >>> _ = f.seek(1)
- >>> f.read().rstrip()
- 'myhostname'
- >>> f.close()
-
- >>> lock.close()
- """
-
-
-class TestLogger(object):
- def __init__(self):
- self.log_entries = []
-
- def exception(self, msg, *args):
- self.log_entries.append((msg,) + args)
-
-
-class LockFileLogEntryTestCase(unittest.TestCase):
- """Tests for logging in case of lock failure"""
- def setUp(self):
- self.here = os.getcwd()
- self.tmp = tempfile.mkdtemp(prefix='zc.lockfile-test-')
- os.chdir(self.tmp)
-
- def tearDown(self):
- os.chdir(self.here)
- setupstack.rmtree(self.tmp)
-
- def test_log_entry(self):
- # PID and hostname are parsed and logged from lock file on failure
- test_logger = TestLogger()
-
- def lock(locked, before_closing):
- lock = None
- try:
- lock = zc.lockfile.LockFile('f.lock',
-
content_template='{pid}/{hostname}')
- except Exception:
- pass
- locked.set()
- before_closing.wait()
- if lock is not None:
- lock.close()
-
- with patch('os.getpid', Mock(return_value=123)):
- with patch('socket.gethostname', Mock(return_value='myhostname')):
- with patch.object(zc.lockfile, 'logger', test_logger):
- first_locked = threading.Event()
- second_locked = threading.Event()
- thread1 = threading.Thread(
- target=lock, args=(first_locked, second_locked))
- thread2 = threading.Thread(
- target=lock, args=(second_locked, second_locked))
- thread1.start()
- first_locked.wait()
- assert not test_logger.log_entries
- thread2.start()
- thread1.join()
- thread2.join()
- expected = [('Error locking file %s; content: "%s%s"',
- 'f.lock', '123/myhostname', '')]
- assert test_logger.log_entries == expected, test_logger.log_entries
-
-
-def test_suite():
- suite = unittest.TestSuite()
- suite.addTest(doctest.DocFileSuite(
- 'README.txt', checker=checker,
- setUp=setupstack.setUpDirectory, tearDown=setupstack.tearDown))
- suite.addTest(doctest.DocTestSuite(
- setUp=setupstack.setUpDirectory, tearDown=setupstack.tearDown,
- checker=checker))
- # Add unittest test cases from this module
- suite.addTest(unittest.defaultTestLoader.loadTestsFromName(__name__))
- return suite
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/zc.lockfile-1.2.1/src/zc.lockfile.egg-info/PKG-INFO
new/zc.lockfile-1.4/src/zc.lockfile.egg-info/PKG-INFO
--- old/zc.lockfile-1.2.1/src/zc.lockfile.egg-info/PKG-INFO 2016-06-19
18:27:21.000000000 +0200
+++ new/zc.lockfile-1.4/src/zc.lockfile.egg-info/PKG-INFO 2018-11-12
10:59:05.000000000 +0100
@@ -1,6 +1,6 @@
-Metadata-Version: 1.1
+Metadata-Version: 2.1
Name: zc.lockfile
-Version: 1.2.1
+Version: 1.4
Summary: Basic inter-process locks
Home-page: http://www.python.org/pypi/zc.lockfile
Author: Zope Foundation
@@ -45,9 +45,10 @@
... print("Can't lock file")
Can't lock file

+ .. We don't log failure to acquire.
+
>>> for record in handler.records: # doctest: +ELLIPSIS
... print(record.levelname+' '+record.getMessage())
- ERROR Error locking file lock; pid=...

To release the lock, use it's close method:

@@ -97,6 +98,23 @@
Change History
***************

+ 1.4 (2018-11-12)
+ ================
+
+ - Claim support for Python 3.6 and 3.7.
+
+ - Drop Python 2.6 and 3.3.
+
+
+ 1.3.0 (2018-04-23)
+ ==================
+
+ - Stop logging failure to acquire locks. Clients can do that if they
wish.
+
+ - Claim support for Python 3.4 and 3.5.
+
+ - Drop Python 3.2 support because pip no longer supports it.
+
1.2.1 (2016-06-19)
==================

@@ -150,9 +168,6 @@

- Initial release

- Download
- **********************
-
Keywords: lock
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
@@ -163,11 +178,13 @@
Classifier: Operating System :: Microsoft :: Windows
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
-Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
-Classifier: Programming Language :: Python :: 3.2
-Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3.6
+Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Software Development
+Provides-Extra: test
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/zc.lockfile-1.2.1/src/zc.lockfile.egg-info/SOURCES.txt
new/zc.lockfile-1.4/src/zc.lockfile.egg-info/SOURCES.txt
--- old/zc.lockfile-1.2.1/src/zc.lockfile.egg-info/SOURCES.txt 2016-06-19
18:27:21.000000000 +0200
+++ new/zc.lockfile-1.4/src/zc.lockfile.egg-info/SOURCES.txt 2018-11-12
10:59:05.000000000 +0100
@@ -1,11 +1,12 @@
-CHANGES.txt
+.gitignore
+.travis.yml
+CHANGES.rst
COPYRIGHT.txt
LICENSE.txt
MANIFEST.in
-README.txt
+README.rst
bootstrap.py
buildout.cfg
-doc.txt
setup.py
tox.ini
src/zc/__init__.py
@@ -18,6 +19,4 @@
src/zc.lockfile.egg-info/top_level.txt
src/zc/lockfile/README.txt
src/zc/lockfile/__init__.py
-src/zc/lockfile/__init__.py~
-src/zc/lockfile/tests.py
-src/zc/lockfile/tests.py~
\ No newline at end of file
+src/zc/lockfile/tests.py
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/zc.lockfile-1.2.1/src/zc.lockfile.egg-info/requires.txt
new/zc.lockfile-1.4/src/zc.lockfile.egg-info/requires.txt
--- old/zc.lockfile-1.2.1/src/zc.lockfile.egg-info/requires.txt 2016-06-19
18:27:21.000000000 +0200
+++ new/zc.lockfile-1.4/src/zc.lockfile.egg-info/requires.txt 2018-11-12
10:59:05.000000000 +0100
@@ -1,4 +1,5 @@
setuptools

[test]
+mock
zope.testing
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/zc.lockfile-1.2.1/tox.ini new/zc.lockfile-1.4/tox.ini
--- old/zc.lockfile-1.2.1/tox.ini 2016-06-09 14:48:53.000000000 +0200
+++ new/zc.lockfile-1.4/tox.ini 2018-11-12 10:59:04.000000000 +0100
@@ -1,6 +1,6 @@
[tox]
envlist =
- py26,py27,py32,py33,pypy,pypy3
+ py27,py34,py35,py36,py37,pypy,pypy3

[testenv]
commands =


< Previous Next >
This Thread
  • No further messages