Hello community,

here is the log from the commit of package python-pytest-services for 
openSUSE:Factory checked in at 2020-11-09 13:56:20
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-pytest-services (Old)
 and      /work/SRC/openSUSE:Factory/.python-pytest-services.new.11331 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-pytest-services"

Mon Nov  9 13:56:20 2020 rev:6 rq:846346 version:2.2.1

Changes:
--------
--- 
/work/SRC/openSUSE:Factory/python-pytest-services/python-pytest-services.changes
    2020-06-30 21:54:36.974415581 +0200
+++ 
/work/SRC/openSUSE:Factory/.python-pytest-services.new.11331/python-pytest-services.changes
 2020-11-09 13:56:46.628047106 +0100
@@ -1,0 +2,9 @@
+Thu Nov  5 15:53:37 UTC 2020 - Marketa Machova <mmach...@suse.com>
+
+- Update to 2.2.1
+  * #38: Retry to lock resource if zc.lockfile.LockError is raised. 
+    Fix needed for pytest-xdist. (StabbarN)
+  * #42: Retry on zc.lockfile.LockError in file_lock, use existing 
+    timeout kwarg (mshriver)
+
+-------------------------------------------------------------------

Old:
----
  2.1.0.tar.gz

New:
----
  2.2.1.tar.gz

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

Other differences:
------------------
++++++ python-pytest-services.spec ++++++
--- /var/tmp/diff_new_pack.PUgjRw/_old  2020-11-09 13:56:47.172045920 +0100
+++ /var/tmp/diff_new_pack.PUgjRw/_new  2020-11-09 13:56:47.176045911 +0100
@@ -19,7 +19,7 @@
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 %bcond_without python2
 Name:           python-pytest-services
-Version:        2.1.0
+Version:        2.2.1
 Release:        0
 Summary:        Services plugin for pytest testing framework
 License:        MIT
@@ -30,6 +30,7 @@
 BuildRequires:  %{python_module pylibmc}
 BuildRequires:  %{python_module pytest}
 BuildRequires:  %{python_module requests}
+BuildRequires:  %{python_module setuptools_scm}
 BuildRequires:  %{python_module setuptools}
 BuildRequires:  %{python_module zc.lockfile >= 2.0}
 BuildRequires:  fdupes

++++++ 2.1.0.tar.gz -> 2.2.1.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest-services-2.1.0/.gitignore 
new/pytest-services-2.2.1/.gitignore
--- old/pytest-services-2.1.0/.gitignore        2020-06-17 00:45:26.000000000 
+0200
+++ new/pytest-services-2.2.1/.gitignore        2020-10-30 13:07:22.000000000 
+0100
@@ -47,3 +47,4 @@
 /include
 /src
 /.env
+/.eggs
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest-services-2.1.0/AUTHORS.rst 
new/pytest-services-2.2.1/AUTHORS.rst
--- old/pytest-services-2.1.0/AUTHORS.rst       2020-06-17 00:45:26.000000000 
+0200
+++ new/pytest-services-2.2.1/AUTHORS.rst       2020-10-30 13:07:22.000000000 
+0100
@@ -10,5 +10,7 @@
 * `Dmitrijs Milajevs <dimaz...@gmail.com>`_
 * `Jason R. Coombs <jar...@jaraco.com>`_
 * `Joep van Dijken <joepvandij...@github.com>`_
+* `Magnus Staberg <mag...@staberg.io>`_
+* `Michael Shriver <mshri...@redhat.com>`_
 * `Oleg Pidsadnyi <oleg.pidsad...@gmail.com>`_
 * `Zac Hatfield-Dodds <z...@zhd.dev>`_
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest-services-2.1.0/CHANGES.rst 
new/pytest-services-2.2.1/CHANGES.rst
--- old/pytest-services-2.1.0/CHANGES.rst       2020-06-17 00:45:26.000000000 
+0200
+++ new/pytest-services-2.2.1/CHANGES.rst       2020-10-30 13:07:22.000000000 
+0100
@@ -1,6 +1,16 @@
 Changelog
 =========
 
+2.2.1
+-----
+
+- #42: Retry on ``zc.lockfile.LockError`` in ``file_lock``, use existing 
timeout kwarg (mshriver)
+
+2.2.0
+-----
+
+- #38: Retry to lock resource if zc.lockfile.LockError is raised. Fix needed 
for pytest-xdist. (StabbarN)
+
 2.1.0
 -----
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest-services-2.1.0/README.rst 
new/pytest-services-2.2.1/README.rst
--- old/pytest-services-2.1.0/README.rst        2020-06-17 00:45:26.000000000 
+0200
+++ new/pytest-services-2.2.1/README.rst        2020-10-30 13:07:22.000000000 
+0100
@@ -115,7 +115,9 @@
 * display_getter
     Function to get unallocated display.
     Automatically ensures locking and un-locking of it on application level 
via flock.
-
+* lock_resource_timeout
+    Used in function lock_resource.
+    A maximum of total sleep between attempts to lock resource.
 
 Service fixtures
 ****************
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest-services-2.1.0/pyproject.toml 
new/pytest-services-2.2.1/pyproject.toml
--- old/pytest-services-2.1.0/pyproject.toml    1970-01-01 01:00:00.000000000 
+0100
+++ new/pytest-services-2.2.1/pyproject.toml    2020-10-30 13:07:22.000000000 
+0100
@@ -0,0 +1,3 @@
+[build-system]
+requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4.1"]
+build-backend = "setuptools.build_meta"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest-services-2.1.0/pytest_services/__init__.py 
new/pytest-services-2.2.1/pytest_services/__init__.py
--- old/pytest-services-2.1.0/pytest_services/__init__.py       2020-06-17 
00:45:26.000000000 +0200
+++ new/pytest-services-2.2.1/pytest_services/__init__.py       2020-10-30 
13:07:22.000000000 +0100
@@ -1,2 +1,2 @@
 """pytest-services package."""
-__version__ = '2.1.0'
+__version__ = '2.2.1'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest-services-2.1.0/pytest_services/locks.py 
new/pytest-services-2.2.1/pytest_services/locks.py
--- old/pytest-services-2.1.0/pytest_services/locks.py  2020-06-17 
00:45:26.000000000 +0200
+++ new/pytest-services-2.2.1/pytest_services/locks.py  2020-10-30 
13:07:22.000000000 +0100
@@ -2,7 +2,9 @@
 import contextlib
 import json
 import os
+from random import random
 import socket
+import time
 
 import pytest
 import zc.lockfile
@@ -22,10 +24,21 @@
     """A lock that is shared across processes.
 
     :param filename: the name of the file that will be locked.
-
+    :param remove: whether or not to remove the file on context close
+    :param timeout: Amount of time to retry the file lock if a 
:class:`zc.lockfile.LockError` is hit
     """
-    with contextlib.closing(zc.lockfile.SimpleLockFile(filename)) as lockfile:
-        yield lockfile._fp
+    total_seconds_slept = 0
+    while True:
+        try:
+            with contextlib.closing(zc.lockfile.SimpleLockFile(filename)) as 
lockfile:
+                yield lockfile._fp
+                break
+        except zc.lockfile.LockError as err:
+            if total_seconds_slept >= timeout:
+                raise err
+        seconds_to_sleep = random() * 0.1 + 0.05
+        total_seconds_slept += seconds_to_sleep
+        time.sleep(seconds_to_sleep)
 
     remove and try_remove(filename)
 
@@ -80,23 +93,39 @@
     return unlock_resource('display', display, lock_dir, services_log)
 
 
-def lock_resource(name, resource_getter, lock_dir, services_log):
-    """Issue a lock for given resource."""
-    with locked_resources(name, lock_dir) as bound_resources:
-        services_log.debug('bound_resources {0}: {1}'.format(name, 
bound_resources))
+@pytest.fixture(scope='session')
+def lock_resource_timeout():
+    """Max number of seconds to obtain the lock."""
+    return 20
 
-        resource = resource_getter(bound_resources)
-        while resource in bound_resources:
-            # resource is already taken by someone, retry
-            services_log.debug('bound resources {0}: {1}'.format(name, 
bound_resources))
-            resource = resource_getter(bound_resources)
-        services_log.debug('free resource choosen {0}: {1}'.format(name, 
resource))
-        bound_resources.append(resource)
-        services_log.debug('bound resources {0}: {1}'.format(name, 
bound_resources))
-        return resource
+
+def lock_resource(name, resource_getter, lock_dir, services_log, 
lock_resource_timeout):
+    """Issue a lock for given resource."""
+    total_seconds_slept = 0
+    while True:
+        try:
+            with locked_resources(name, lock_dir) as bound_resources:
+                services_log.debug('bound_resources {0}: {1}'.format(name, 
bound_resources))
+                resource = resource_getter(bound_resources)
+                while resource in bound_resources:
+                    # resource is already taken by someone, retry
+                    services_log.debug('bound resources {0}: {1}'.format(name, 
bound_resources))
+                    resource = resource_getter(bound_resources)
+                services_log.debug('free resource choosen {0}: 
{1}'.format(name, resource))
+                bound_resources.append(resource)
+                services_log.debug('bound resources {0}: {1}'.format(name, 
bound_resources))
+                return resource
+        except zc.lockfile.LockError as err:
+            if total_seconds_slept >= lock_resource_timeout:
+                raise err
+            services_log.debug('lock resource failed: {0}'.format(err))
+
+        seconds_to_sleep = random() * 0.1 + 0.05
+        total_seconds_slept += seconds_to_sleep
+        time.sleep(seconds_to_sleep)
 
 
-def get_free_port(lock_dir, services_log):
+def get_free_port(lock_dir, services_log, lock_resource_timeout):
     """Get free port to listen on."""
     def get_port(bound_resources):
         if bound_resources:
@@ -114,10 +143,10 @@
                 pass
             port += 1
 
-    return lock_resource('port', get_port, lock_dir, services_log)
+    return lock_resource('port', get_port, lock_dir, services_log, 
lock_resource_timeout)
 
 
-def get_free_display(lock_dir, services_log):
+def get_free_display(lock_dir, services_log, lock_resource_timeout):
     """Get free display to listen on."""
     def get_display(bound_resources):
         display = 100
@@ -129,15 +158,15 @@
                 continue
             return display
 
-    return lock_resource('display', get_display, lock_dir, services_log)
+    return lock_resource('display', get_display, lock_dir, services_log, 
lock_resource_timeout)
 
 
 @pytest.fixture(scope='session')
-def port_getter(request, lock_dir, services_log):
+def port_getter(request, lock_dir, services_log, lock_resource_timeout):
     """Lock getter function."""
     def get_port():
         """Lock a free port and unlock it on finalizer."""
-        port = get_free_port(lock_dir, services_log)
+        port = get_free_port(lock_dir, services_log, lock_resource_timeout)
 
         def finalize():
             unlock_port(port, lock_dir, services_log)
@@ -147,11 +176,11 @@
 
 
 @pytest.fixture(scope='session')
-def display_getter(request, lock_dir, services_log):
+def display_getter(request, lock_dir, services_log, lock_resource_timeout):
     """Display getter function."""
     def get_display():
         """Lock a free display and unlock it on finalizer."""
-        display = get_free_display(lock_dir, services_log)
+        display = get_free_display(lock_dir, services_log, 
lock_resource_timeout)
         request.addfinalizer(lambda: unlock_display(display, lock_dir, 
services_log))
         return display
     return get_display
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest-services-2.1.0/setup.cfg 
new/pytest-services-2.2.1/setup.cfg
--- old/pytest-services-2.1.0/setup.cfg 1970-01-01 01:00:00.000000000 +0100
+++ new/pytest-services-2.2.1/setup.cfg 2020-10-30 13:07:22.000000000 +0100
@@ -0,0 +1,6 @@
+[bdist_wheel]
+universal = 1
+
+[options]
+# for compatibility with older installers
+setup_requires = setuptools_scm[toml] >= 3.4.1
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest-services-2.1.0/setup.py 
new/pytest-services-2.2.1/setup.py
--- old/pytest-services-2.1.0/setup.py  2020-06-17 00:45:26.000000000 +0200
+++ new/pytest-services-2.2.1/setup.py  2020-10-30 13:07:22.000000000 +0100
@@ -2,20 +2,19 @@
 import codecs
 import os
 import sys
+import re
 
 from setuptools import setup
 
-import pytest_services
-
 dirname = os.path.dirname(__file__)
 
 long_description = (
     codecs.open(os.path.join(dirname, 'README.rst'), encoding='utf-8').read() 
+ '\n' +
+    codecs.open(os.path.join(dirname, 'AUTHORS.rst'), encoding='utf-8').read() 
+ '\n' +
     codecs.open(os.path.join(dirname, 'CHANGES.rst'), encoding='utf-8').read()
 )
 
 install_requires = [
-    'setuptools',
     'requests',
     'psutil',
     'pytest',
@@ -27,6 +26,9 @@
 if PY2:
     install_requires.append('subprocess32')
 
+with codecs.open(os.path.join(dirname, "pytest_services", "__init__.py"), 
encoding="utf-8") as fd:
+    VERSION = re.compile(r".*__version__ = ['\"](.*?)['\"]", 
re.S).match(fd.read()).group(1)
+
 
 setup(
     name='pytest-services',
@@ -35,7 +37,7 @@
     author='Anatoly Bubenkov, Paylogic International and others',
     license='MIT license',
     author_email='bubenk...@gmail.com',
-    version=pytest_services.__version__,
+    version=VERSION,
     url='https://github.com/pytest-dev/pytest-services',
     install_requires=install_requires,
     extras={


Reply via email to