summary refs log tree commit diff
path: root/synapse/util/__init__.py (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Use immutabledict instead of frozendict (#15113)David Robertson2023-03-221-12/+8
| | | | | | | | | | Additionally: * Consistently use `freeze()` in test --------- Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com> Co-authored-by: 6543 <6543@obermui.de>
* Always close _all_ `ijson` coroutines, even if doing so raises Exceptions ↵David Robertson2022-10-061-1/+13
| | | | (#14065)
* Type `tests.utils` (#13028)David Robertson2022-07-051-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Cast to postgres types when handling postgres db * Remove unused method * Easy annotations * Annotate create_room * Use `ParamSpec` to annotate looping_call * Annotate `default_config` * Track `now` as a float `time_ms` returns an int like the proper Synapse `Clock` * Introduce a `Timer` dataclass * Introduce a Looper type * Suppress checking of a mock * tests.utils is typed * Changelog * Whoops, import ParamSpec from typing_extensions * ditch the psycopg2 casts
* Fix Synapse git info missing in version strings (#12973)David Robertson2022-06-071-0/+6
|
* Remove workaround introduced in Synapse v1.50.0rc1 for Mjolnir ↵reivilibre2022-03-101-7/+0
| | | | compatibility. Breaks compatibility with Mjolnir v1.3.1 and earlier. (#11700)
* Improve exception handling for concurrent execution (#12109)Richard van der Hoff2022-03-011-1/+3
| | | | | | | | | | | | | | | * fix incorrect unwrapFirstError import this was being imported from the wrong place * Refactor `concurrently_execute` to use `yieldable_gather_results` * Improve exception handling in `yieldable_gather_results` Try to avoid swallowing so many stack traces. * mark unwrapFirstError deprecated * changelog
* Work around Mjolnir compatibility issue by adding an import for ↵reivilibre2022-01-061-0/+7
| | | | `glob_to_regex` in `synapse.util`, where it moved from. (#11696)
* Re-apply: Move glob_to_regex and re_word_boundary to matrix-python-common ↵reivilibre2022-01-051-58/+1
| | | | | #11505 (#11687) Co-authored-by: Sean Quah <seanq@element.io>
* Revert "Move `glob_to_regex` and `re_word_boundary` to ↵Sean Quah2021-12-071-1/+58
| | | | | | `matrix-python-common` (#11505) (#11527) This reverts commit a77c36989785c0d5565ab9a1169f4f88e512ce8a.
* Move `glob_to_regex` and `re_word_boundary` to `matrix-python-common` (#11505)Sean Quah2021-12-061-58/+1
|
* Add more type hints to synapse.util. (#11321)Patrick Cloke2021-11-121-12/+20
|
* Relax `ignore-missing-imports` for modules that have stubs now and update ↵David Robertson2021-10-081-1/+4
| | | | | | | | | | | | mypy (#11006) Updating mypy past version 0.9 means that third-party stubs are no-longer distributed with typeshed. See http://mypy-lang.blogspot.com/2021/06/mypy-0900-released.html for details. We therefore pull in stub packages in setup.py Additionally, some modules that we were previously ignoring import failures for now have stubs. So let's use them. The rest of this change consists of fixups to make the newer mypy + stubs pass CI. Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* Update utility code to handle C implementations of frozendict (#10902)Hillery Shay2021-09-281-1/+7
| | | | | | | * update _handle_frozendict to work with c implementations of frozen dict * add changelog * add clarifying comment to _handle_frozendict
* Add types to synapse.util. (#10601)reivilibre2021-09-101-16/+24
|
* Merge pull request from GHSA-x345-32rc-8h85Richard van der Hoff2021-05-111-14/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * tests for push rule pattern matching * tests for acl pattern matching * factor out common `re.escape` * Factor out common re.compile * Factor out common anchoring code * add word_boundary support to `glob_to_regex` * Use `glob_to_regex` in push rule evaluator NB that this drops support for character classes. I don't think anyone ever used them. * Improve efficiency of globs with multiple wildcards The idea here is that we compress multiple `*` globs into a single `.*`. We also need to consider `?`, since `*?*` is as hard to implement efficiently as `**`. * add assertion on regex pattern * Fix mypy * Simplify glob_to_regex * Inline the glob_to_regex helper function Signed-off-by: Dan Callahan <danc@element.io> * Moar comments Signed-off-by: Dan Callahan <danc@element.io> Co-authored-by: Dan Callahan <danc@element.io>
* Remove redundant "coding: utf-8" lines (#9786)Jonathan de Jong2021-04-141-1/+0
| | | | | | | Part of #9744 Removes all redundant `# -*- coding: utf-8 -*-` lines from files, as python 3 automatically reads source code as utf-8 now. `Signed-off-by: Jonathan de Jong <jonathan@automatia.nl>`
* Remove frozendict_json_encoder and support frozendicts everywhereRichard van der Hoff2020-10-281-3/+21
| | | | | | Not being able to serialise `frozendicts` is fragile, and it's annoying to have to think about which serialiser you want. There's no real downside to supporting frozendicts, so let's just have one json encoder.
* Use slots in attrs classes where possible (#8296)Patrick Cloke2020-09-141-1/+1
| | | | | slots use less memory (and attribute access is faster) while slightly limiting the flexibility of the class attributes. This focuses on objects which are instantiated "often" and for short periods of time.
* Merge tag 'v1.20.0rc3' into developPatrick Cloke2020-09-111-1/+1
|\ | | | | | | | | | | | | | | | | | | Synapse 1.20.0rc3 (2020-09-11) ============================== Bugfixes -------- - Fix a bug introduced in v1.20.0rc1 where the wrong exception was raised when invalid JSON data is encountered. ([\#8291](https://github.com/matrix-org/synapse/issues/8291))
| * Fix the exception that is raised when invalid JSON is encountered. (#8291)Patrick Cloke2020-09-101-1/+1
| |
* | Directly import json from the standard library. (#8259)Patrick Cloke2020-09-081-1/+1
|/ | | | | By importing from canonicaljson the simplejson module was still being used in some situations. After this change the std lib json is consistenty used throughout Synapse.
* Stop sub-classing object (#8249)Patrick Cloke2020-09-041-1/+1
|
* Be stricter about JSON that is accepted by Synapse (#8106)Patrick Cloke2020-08-191-2/+12
|
* Reduce unnecessary whitespace in JSON. (#7372)David Vo2020-08-071-0/+4
|
* Fix some spelling mistakes / typos. (#7811)Patrick Cloke2020-07-091-1/+1
|
* move batch_iter to a separate moduleRichard van der Hoff2020-01-161-17/+0
|
* Add kwargs and docBrendan Abolivier2019-07-291-2/+4
|
* Add ability to pass arguments to looping callsBrendan Abolivier2019-07-291-2/+2
|
* Replace returnValue with return (#5736)Amber Brown2019-07-231-1/+1
|
* Improve the backwards compatibility re-exports of synapse.logging.context ↵Amber Brown2019-07-051-5/+1
| | | | | | | | (#5617) * Improve the backwards compatibility re-exports of synapse.logging.context. * reexport logformatter too
* Move logging utilities out of the side drawer of util/ and into logging/ (#5606)Amber Brown2019-07-041-4/+8
|
* Fix a number of "Starting txn from sentinel context" warnings (#5605)Richard van der Hoff2019-07-031-1/+7
| | | | Fixes #5602, #5603
* Run Black. (#5482)Amber Brown2019-06-201-14/+9
|
* Anchor returned regex to start and end of stringErik Johnston2018-10-191-2/+6
|
* Add config option to control alias creationErik Johnston2018-10-191-0/+21
|
* Remove unnecessary extra function call layerErik Johnston2018-10-081-16/+13
|
* Use errback pattern and catch async failuresErik Johnston2018-10-081-14/+29
|
* Log looping call exceptionsErik Johnston2018-10-051-1/+18
| | | | | | | | If a looping call function errors, then it kills the loop entirely. Currently it throws away the exception logs, so we should make it actually log them. Fixes #3929
* run isortAmber Brown2018-07-091-0/+1
|
* Remove all global reactor imports & pass it around explicitly (#3424)Amber Brown2018-06-251-0/+3
|
* Pass around the reactor explicitly (#3385)Amber Brown2018-06-221-12/+20
|
* Add batch_iter to utilsAdrian Tschira2018-05-191-0/+18
| | | | | | | | | There's a frequent idiom I noticed where an iterable is split up into a number of chunks/batches. Unfortunately that method does not work with iterators like dict.keys() in python3. This implementation works with iterators. Signed-off-by: Adrian Tschira <nota@notafile.com>
* Use deferred.addTimeout instead of time_bound_deferredRichard van der Hoff2018-04-231-56/+0
| | | | This doesn't feel like a wheel we need to reinvent.
* fix vars named `l`Richard van der Hoff2017-10-231-3/+3
| | | | E741 says "do not use variables named ‘l’, ‘O’, or ‘I’".
* replace 'except:' with 'except Exception:'Richard van der Hoff2017-10-231-6/+6
| | | | what could possibly go wrong
* Instantiate DeferredTimedOutError correctlyRichard van der Hoff2017-05-021-1/+1
| | | | | | Call `super` correctly, so that we correctly initialise the `errcode` field. Fixes https://github.com/matrix-org/synapse/issues/2179.
* Fix time_bound_deferred to throw the right exceptionRichard van der Hoff2017-03-231-4/+6
| | | | | | Due to a failure to instantiate DeferredTimedOutError, time_bound_deferred would throw a CancelledError when the deferred timed out, which was rather confusing.
* Correctly handle timeout errorsErik Johnston2016-12-091-1/+6
|
* Clean transactions based on time. Add HttpTransactionCache tests.Kegan Dougal2016-11-141-1/+9
|
* Use SynapseError 504 for Timeout errorsErik Johnston2016-04-151-1/+2
|
* Remove some unused functions (#711)Mark Haines2016-04-081-3/+0
| | | | | | | | * Remove some unused functions * get_room_events_stream is only used in tests * is_exclusive_room might actually be something we want
* Initial cutErik Johnston2016-02-171-1/+1
|
* Fix up logcontextsErik Johnston2016-02-081-4/+2
|
* Fix flake8 warnings for new flake8Daniel Wagner-Hall2016-02-021-1/+1
|
* copyrightsMatthew Hodgson2016-01-071-1/+1
|
* Track the cpu used in the main thread by each logging contextMark Haines2015-12-031-2/+1
|
* Run the background updates when starting synapse.Mark Haines2015-11-101-0/+8
|
* synapse/util/__init__.py:unwrap_deferred was unusedMark Haines2015-09-221-28/+0
|
* Refactor the notifier.wait_for_events code to be clearer. Add ↵Erik Johnston2015-06-181-2/+6
| | | | _NotifierUserStream.new_listener that accpets a token to avoid races.
* Awful idea for speeding up fetching of eventsErik Johnston2015-05-141-4/+4
|
* Refactor _get_eventsErik Johnston2015-05-141-0/+28
|
* Unwrap defer.gatherResults failuresErik Johnston2015-05-121-0/+6
|
* Fix up leak. Add warnings.Erik Johnston2015-05-081-1/+2
|
* Change the way we do logging contexts so that they survive divergencesErik Johnston2015-05-081-3/+5
|
* Consume errors in time_bound_deferredErik Johnston2015-02-171-2/+0
|
* Fix so timing out connections to actually work.Erik Johnston2015-02-111-9/+43
|
* Merge branch 'develop' of github.com:matrix-org/synapse into ↵Erik Johnston2015-02-111-1/+9
|\ | | | | | | timeout-federation-requests
| * Add looping_call to ClockErik Johnston2015-02-091-1/+9
| |
* | Move time_bound_deferred into ClockErik Johnston2015-02-111-1/+20
|/
* Update copyright noticesMark Haines2015-01-061-1/+1
|
* Fix pep8 codestyle warningsMark Haines2014-11-201-0/+1
|
* Sometimes there isn't a current logging contextMark Haines2014-11-191-1/+1
|
* Preserve logging context in a few more places, drop the logging context ↵Mark Haines2014-11-191-1/+6
| | | | after it has been stashed to reduce potential for confusion
* fix the copyright holder from matrix.org to OpenMarket Ltd, as matrix.org ↵Matthew Hodgson2014-09-031-1/+1
| | | | hasn't been incorporated in time for launch.
* add in whitespace after copyright statements to improve legibilityMatthew Hodgson2014-08-131-0/+1
|
* Reference Matrix Home Servermatrix.org2014-08-121-0/+40