django / asgi_ipc

IPC-based ASGI channel layer
BSD 3-Clause "New" or "Revised" License
37 stars 13 forks source link

Unable to use layer with python 3.6 #31

Closed hoefling closed 7 years ago

hoefling commented 7 years ago

First thought this is the same issue as in #26 as I got the same error in a docker container built on top of python:3.6.2-stretch, but also reproducible on a host machine. Using example from the readme:

$ pip3.6 install --user asgi_ipc
Collecting asgi_ipc
  Using cached asgi_ipc-1.4.0-py2.py3-none-any.whl
Collecting msgpack-python (from asgi_ipc)
Collecting asgiref~=1.1.2 (from asgi_ipc)
  Using cached asgiref-1.1.2-py2.py3-none-any.whl
Collecting posix-ipc>=1.0.0 (from asgi_ipc)
Requirement already satisfied: six in /usr/lib64/python3.6/site-packages (from asgi_ipc)
Installing collected packages: msgpack-python, asgiref, posix-ipc, asgi-ipc
Successfully installed asgi-ipc-1.4.0 asgiref-1.1.2 msgpack-python-0.4.8 posix-ipc-1.0.0
$ 
$ python3.6
Python 3.6.1 (default, Apr 26 2017, 12:37:57) 
[GCC 6.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import asgi_ipc
>>> import asgi_ipc as asgi
>>> channel_layer = asgi.IPCChannelLayer(
...     prefix="aeracode",
...     message_memory=200 * 1024 * 1024,
... )
>>> channel_layer.send("my_channel", {"text": "Hello ASGI"})
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/hoefling/.local/lib64/python3.6/site-packages/asgi_ipc/core.py", line 61, in send
    channel_size = self.message_store.length(channel)
  File "/home/hoefling/.local/lib64/python3.6/site-packages/asgi_ipc/store.py", line 134, in length
    with self.mutate_value() as value:
  File "/usr/lib64/python3.6/contextlib.py", line 82, in __enter__
    return next(self.gen)
  File "/home/hoefling/.local/lib64/python3.6/site-packages/asgi_ipc/store.py", line 50, in mutate_value
    value = pickle.load(self.mmap)
_pickle.UnpicklingError: invalid load key, '\x00'.
>>>

Not reproducible with python 3.5:

$ python3.5
Python 3.5.3 (default, Mar 25 2017, 06:59:48) 
[GCC 6.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import asgi_ipc as asgi
>>> channel_layer = asgi.IPCChannelLayer(
...     prefix="aeracode",
...     message_memory=200 * 1024 * 1024,
... )
>>> channel_layer.send("my_channel", {"text": "Hello ASGI"})
>>> exit()
proofit404 commented 7 years ago

Hi, did you try package version from master? I'm not sure we released related fix.

hoefling commented 7 years ago

Indeed it works from trunk; requesting new release then...

andrewgodwin commented 7 years ago

Just put out 1.4.1.