summary refs log tree commit diff
path: root/synapse/replication
diff options
context:
space:
mode:
authorRichard van der Hoff <1389908+richvdh@users.noreply.github.com>2018-04-03 15:18:32 +0100
committerGitHub <noreply@github.com>2018-04-03 15:18:32 +0100
commit8da39ad98fbcc9c4d153ad6a32d7e0fed1f9c0ad (patch)
treee9ec751fe38217b35a34a38a01cb7019d261031e /synapse/replication
parentMerge pull request #3048 from matrix-org/rav/use_simplejson (diff)
parentFix json encoding bug in replication (diff)
downloadsynapse-8da39ad98fbcc9c4d153ad6a32d7e0fed1f9c0ad.tar.xz
Merge pull request #3049 from matrix-org/rav/use_staticjson
Use static JSONEncoders
Diffstat (limited to 'synapse/replication')
-rw-r--r--synapse/replication/tcp/commands.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/synapse/replication/tcp/commands.py b/synapse/replication/tcp/commands.py
index 0005ad5879..12aac3cc6b 100644
--- a/synapse/replication/tcp/commands.py
+++ b/synapse/replication/tcp/commands.py
@@ -24,6 +24,8 @@ import simplejson
 
 logger = logging.getLogger(__name__)
 
+_json_encoder = simplejson.JSONEncoder(namedtuple_as_object=False)
+
 
 class Command(object):
     """The base command class.
@@ -107,7 +109,7 @@ class RdataCommand(Command):
         return " ".join((
             self.stream_name,
             str(self.token) if self.token is not None else "batch",
-            simplejson.dumps(self.row, namedtuple_as_object=False),
+            _json_encoder.encode(self.row),
         ))
 
 
@@ -302,7 +304,7 @@ class InvalidateCacheCommand(Command):
 
     def to_line(self):
         return " ".join((
-            self.cache_func, simplejson.dumps(self.keys, namedtuple_as_object=False)
+            self.cache_func, _json_encoder.encode(self.keys),
         ))
 
 
@@ -334,7 +336,7 @@ class UserIpCommand(Command):
         )
 
     def to_line(self):
-        return self.user_id + " " + simplejson.dumps((
+        return self.user_id + " " + _json_encoder.encode((
             self.access_token, self.ip, self.user_agent, self.device_id,
             self.last_seen,
         ))