Verified Commit 14d5b0c6 authored by Eliot Berriot's avatar Eliot Berriot
Browse files

Revert to apline:3.11 to stay on Python 3.7 (3.8 has issues with channels)

parent 9a287646
Pipeline #9672 canceled with stages
in 3 minutes and 11 seconds
FROM alpine:3.11 FROM alpine:3.10
RUN \ RUN \
echo 'installing dependencies' && \ echo 'installing dependencies' && \
......
...@@ -544,7 +544,7 @@ CHANNEL_LAYERS = { ...@@ -544,7 +544,7 @@ CHANNEL_LAYERS = {
} }
CACHES["default"]["OPTIONS"] = { CACHES["default"]["OPTIONS"] = {
"CLIENT_CLASS": "django_redis.client.DefaultClient", "CLIENT_CLASS": "funkwhale_api.common.cache.RedisClient",
"IGNORE_EXCEPTIONS": True, # mimics memcache behavior. "IGNORE_EXCEPTIONS": True, # mimics memcache behavior.
# http://niwinz.github.io/django-redis/latest/#_memcached_exceptions_behavior # http://niwinz.github.io/django-redis/latest/#_memcached_exceptions_behavior
} }
......
import logging
from django_redis.client import default
logger = logging.getLogger(__name__)
class RedisClient(default.DefaultClient):
def get(self, key, default=None, version=None, client=None):
try:
return super().get(key, default=None, version=None, client=None)
except ValueError as e:
if "unsupported pickle protocol" in str(e):
# pickle deserialization error
logger.warn("Error while deserializing pickle value from cache")
return default
else:
raise
def get_many(self, *args, **kwargs):
try:
return super().get_many(*args, **kwargs)
except ValueError as e:
if "unsupported pickle protocol" in str(e):
# pickle deserialization error
logger.warn("Error while deserializing pickle value from cache")
return {}
else:
raise
...@@ -8,6 +8,7 @@ from django.core.serializers.json import DjangoJSONEncoder ...@@ -8,6 +8,7 @@ from django.core.serializers.json import DjangoJSONEncoder
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
channel_layer = get_channel_layer() channel_layer = get_channel_layer()
group_add = async_to_sync(channel_layer.group_add) group_add = async_to_sync(channel_layer.group_add)
group_discard = async_to_sync(channel_layer.group_discard)
def group_send(group, event): def group_send(group, event):
......
...@@ -14,7 +14,11 @@ class JsonAuthConsumer(JsonWebsocketConsumer): ...@@ -14,7 +14,11 @@ class JsonAuthConsumer(JsonWebsocketConsumer):
def accept(self): def accept(self):
super().accept() super().accept()
for group in self.groups: groups = self.scope["user"].get_channels_groups() + self.groups
channels.group_add(group, self.channel_name) for group in groups:
for group in self.scope["user"].get_channels_groups():
channels.group_add(group, self.channel_name) channels.group_add(group, self.channel_name)
def disconnect(self, close_code):
groups = self.scope["user"].get_channels_groups() + self.groups
for group in groups:
channels.group_discard(group, self.channel_name)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment