mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-10-01 11:49:51 -04:00
commit
36501068d8
@ -24,7 +24,9 @@ import shutil
|
|||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
import simplejson as json
|
import simplejson as json
|
||||||
import urlparse
|
|
||||||
|
from six.moves import urllib_parse as urlparse
|
||||||
|
from six import string_types
|
||||||
|
|
||||||
from twisted.web.server import NOT_DONE_YET
|
from twisted.web.server import NOT_DONE_YET
|
||||||
from twisted.internet import defer
|
from twisted.internet import defer
|
||||||
@ -590,8 +592,8 @@ def _iterate_over_text(tree, *tags_to_ignore):
|
|||||||
# to be returned.
|
# to be returned.
|
||||||
elements = iter([tree])
|
elements = iter([tree])
|
||||||
while True:
|
while True:
|
||||||
el = elements.next()
|
el = next(elements)
|
||||||
if isinstance(el, basestring):
|
if isinstance(el, string_types):
|
||||||
yield el
|
yield el
|
||||||
elif el is not None and el.tag not in tags_to_ignore:
|
elif el is not None and el.tag not in tags_to_ignore:
|
||||||
# el.text is the text before the first child, so we can immediately
|
# el.text is the text before the first child, so we can immediately
|
||||||
|
@ -30,6 +30,12 @@ import threading
|
|||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
try:
|
||||||
|
MAX_TXN_ID = sys.maxint - 1
|
||||||
|
except AttributeError:
|
||||||
|
# python 3 does not have a maximum int value
|
||||||
|
MAX_TXN_ID = 2**63 - 1
|
||||||
|
|
||||||
sql_logger = logging.getLogger("synapse.storage.SQL")
|
sql_logger = logging.getLogger("synapse.storage.SQL")
|
||||||
transaction_logger = logging.getLogger("synapse.storage.txn")
|
transaction_logger = logging.getLogger("synapse.storage.txn")
|
||||||
perf_logger = logging.getLogger("synapse.storage.TIME")
|
perf_logger = logging.getLogger("synapse.storage.TIME")
|
||||||
@ -222,7 +228,7 @@ class SQLBaseStore(object):
|
|||||||
|
|
||||||
# We don't really need these to be unique, so lets stop it from
|
# We don't really need these to be unique, so lets stop it from
|
||||||
# growing really large.
|
# growing really large.
|
||||||
self._TXN_ID = (self._TXN_ID + 1) % (sys.maxint - 1)
|
self._TXN_ID = (self._TXN_ID + 1) % (MAX_TXN_ID)
|
||||||
|
|
||||||
name = "%s-%x" % (desc, txn_id, )
|
name = "%s-%x" % (desc, txn_id, )
|
||||||
|
|
||||||
|
@ -16,6 +16,9 @@
|
|||||||
import synapse.metrics
|
import synapse.metrics
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from six.moves import intern
|
||||||
|
import six
|
||||||
|
|
||||||
CACHE_SIZE_FACTOR = float(os.environ.get("SYNAPSE_CACHE_FACTOR", 0.5))
|
CACHE_SIZE_FACTOR = float(os.environ.get("SYNAPSE_CACHE_FACTOR", 0.5))
|
||||||
|
|
||||||
metrics = synapse.metrics.get_metrics_for("synapse.util.caches")
|
metrics = synapse.metrics.get_metrics_for("synapse.util.caches")
|
||||||
@ -66,7 +69,9 @@ def intern_string(string):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
string = string.encode("ascii")
|
if six.PY2:
|
||||||
|
string = string.encode("ascii")
|
||||||
|
|
||||||
return intern(string)
|
return intern(string)
|
||||||
except UnicodeEncodeError:
|
except UnicodeEncodeError:
|
||||||
return string
|
return string
|
||||||
|
Loading…
Reference in New Issue
Block a user