How to use custom JSON encoder with PubSub managers after pickle deprecation? #1548
-
|
Following the fix in #1502, Would it be possible to use the JSON encoder from the server instance instead? This would allow custom encoders configured on the server to be respected by the manager. For example, in class AsyncRedisManager(AsyncPubSubManager):
async def _publish(self, data): # pragma: no cover
_, error = self._get_redis_module_and_error()
for retries_left in range(1, -1, -1): # 2 attempts
try:
if not self.connected:
self._redis_connect()
- return await self.redis.publish(
- self.channel, json.dumps(data))
+ return await self.redis.publish(
+ self.channel, self.server.packet_class.json.dumps(data))
except error as exc:
if retries_left > 0:
self._get_logger().error(
'Cannot publish to redis... '
'retrying',
extra={"redis_exception": str(exc)})
self.connected = False
else:
self._get_logger().error(
'Cannot publish to redis... '
'giving up',
extra={"redis_exception": str(exc)})
breakQuestions:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
|
I'm not sure I understand what the problem is, because |
Beta Was this translation helpful? Give feedback.
Thanks. You are correct, this is a bug and I will fix it. Added #1549 to track it.