[Python-modules-commits] [python-asgi-ipc] 10/13: New upstream version 1.4.2

Michael Fladischer fladi at moszumanska.debian.org
Fri Nov 17 12:24:56 UTC 2017


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

fladi pushed a commit to branch debian/master
in repository python-asgi-ipc.

commit 9a32eb7b36324d8cb0b941d7d237fe967839b029
Author: Michael Fladischer <FladischerMichael at fladi.at>
Date:   Fri Nov 17 13:09:42 2017 +0100

    New upstream version 1.4.2
---
 .travis.yml       |  2 ++
 CHANGELOG.txt     | 12 ++++++++++++
 asgi_ipc/store.py | 28 +++++++++++++++++++---------
 setup.py          |  2 +-
 4 files changed, 34 insertions(+), 10 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index a3764a8..9f9fdfa 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,9 +1,11 @@
 sudo: false
+dist: trusty
 language: python
 python:
   - "2.7"
   - "3.4"
   - "3.5"
+  - "3.6"
 install:
   - pip install -e .
 script:
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index f96249d..029aa57 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -1,3 +1,15 @@
+1.4.2 (2017-10-26)
+------------------
+
+* Fix KeyError for empty groups
+
+
+1.4.1 (2017-08-11)
+------------------
+
+* Fix empty shared memory area bug
+
+
 1.4.0 (2017-05-24)
 ------------------
 
diff --git a/asgi_ipc/store.py b/asgi_ipc/store.py
index 672a36d..4df849e 100644
--- a/asgi_ipc/store.py
+++ b/asgi_ipc/store.py
@@ -46,10 +46,17 @@ class BaseMemoryStore(object):
         try:
             # Load the value from the shared memory segment (if populated)
             self.mmap.seek(0)
-            try:
-                value = pickle.load(self.mmap)
-            except EOFError:
+            # Memory can be empty but have a length.  Pickle opcodes
+            # starts at 0x80.  If we read zero, memory was not
+            # initiated yet.
+            if not self.mmap.read_byte():
                 value = self.DEFAULT_FACTORY()
+            else:
+                self.mmap.seek(0)
+                try:
+                    value = pickle.load(self.mmap)
+                except EOFError:
+                    value = self.DEFAULT_FACTORY()
             # Let the inside run
             yield value
             # Dump the value back into the shared memory segment
@@ -182,11 +189,14 @@ class GroupMemoryStore(BaseMemoryStore):
         Removes all members from the group who have expired, and returns the
         new list of members.
         """
-        with self.mutate_value() as value:
-            value[name] = {
-                item: expiry
-                for item, expiry in value[name].items()
-                if expiry >= time.time()
-            }
+        try:
+            with self.mutate_value() as value:
+                value[name] = {
+                    item: expiry
+                    for item, expiry in value[name].items()
+                    if expiry >= time.time()
+                }
+        except KeyError:
+            return []
         return value[name].keys()
 
diff --git a/setup.py b/setup.py
index f2cdd6f..35df32a 100644
--- a/setup.py
+++ b/setup.py
@@ -1,7 +1,7 @@
 import os
 from setuptools import setup
 
-__version__ = '1.4.0'
+__version__ = '1.4.2'
 
 # We use the README as the long_description
 readme_path = os.path.join(os.path.dirname(__file__), "README.rst")

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



More information about the Python-modules-commits mailing list