Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Fix replication after switch to simplejson #3015

Merged
merged 2 commits into from
Mar 20, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions synapse/replication/tcp/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"""

import logging
import simplejson as json
import simplejson


logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -100,14 +100,14 @@ def from_line(cls, line):
return cls(
stream_name,
None if token == "batch" else int(token),
json.loads(row_json)
simplejson.loads(row_json)
)

def to_line(self):
return " ".join((
self.stream_name,
str(self.token) if self.token is not None else "batch",
json.dumps(self.row),
simplejson.dumps(self.row, namedtuple_as_object=False),
))


Expand Down Expand Up @@ -298,10 +298,12 @@ def __init__(self, cache_func, keys):
def from_line(cls, line):
cache_func, keys_json = line.split(" ", 1)

return cls(cache_func, json.loads(keys_json))
return cls(cache_func, simplejson.loads(keys_json))

def to_line(self):
return " ".join((self.cache_func, json.dumps(self.keys)))
return " ".join((
self.cache_func, simplejson.dumps(self.keys, namedtuple_as_object=False)
))


class UserIpCommand(Command):
Expand All @@ -325,14 +327,14 @@ def __init__(self, user_id, access_token, ip, user_agent, device_id, last_seen):
def from_line(cls, line):
user_id, jsn = line.split(" ", 1)

access_token, ip, user_agent, device_id, last_seen = json.loads(jsn)
access_token, ip, user_agent, device_id, last_seen = simplejson.loads(jsn)

return cls(
user_id, access_token, ip, user_agent, device_id, last_seen
)

def to_line(self):
return self.user_id + " " + json.dumps((
return self.user_id + " " + simplejson.dumps((
self.access_token, self.ip, self.user_agent, self.device_id,
self.last_seen,
))
Expand Down