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

Commit 059e0fd

Browse files
committed
Merge commit '5bf8e5f55' into anoa/dinsic_release_1_21_x
* commit '5bf8e5f55': Convert the well known resolver to async (#8214) Convert additional databases to async/await part 2 (#8200) Make MultiWriterIDGenerator work for streams that use negative stream IDs (#8203) Do not install setuptools 50.0. (#8212) Move and rename `get_devices_with_keys_by_user` (#8204) Rename `get_e2e_device_keys` to better reflect its purpose (#8205) Add a comment about _LimitedHostnameResolver
2 parents d49dd2f + 5bf8e5f commit 059e0fd

36 files changed

+392
-195
lines changed

INSTALL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ mkdir -p ~/synapse
7373
virtualenv -p python3 ~/synapse/env
7474
source ~/synapse/env/bin/activate
7575
pip install --upgrade pip
76-
pip install --upgrade setuptools
76+
pip install --upgrade setuptools!=50.0 # setuptools==50.0 fails on some older Python versions
7777
pip install matrix-synapse
7878
```
7979

changelog.d/8200.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Convert various parts of the codebase to async/await.

changelog.d/8203.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Make `MultiWriterIDGenerator` work for streams that use negative values.

changelog.d/8204.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Refactor queries for device keys and cross-signatures.

changelog.d/8205.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Refactor queries for device keys and cross-signatures.

changelog.d/8212.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Do not install setuptools 50.0. It can lead to a broken configuration on some older Python versions.

changelog.d/8214.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Convert various parts of the codebase to async/await.

mypy.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ files =
2828
synapse/handlers/saml_handler.py,
2929
synapse/handlers/sync.py,
3030
synapse/handlers/ui_auth,
31+
synapse/http/federation/well_known_resolver.py,
3132
synapse/http/server.py,
3233
synapse/http/site.py,
3334
synapse/logging/,

synapse/app/_base.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,13 @@ def install_dns_limiter(reactor, max_dns_requests_in_flight=100):
334334
This is to workaround https://twistedmatrix.com/trac/ticket/9620, where we
335335
can run out of file descriptors and infinite loop if we attempt to do too
336336
many DNS queries at once
337+
338+
XXX: I'm confused by this. reactor.nameResolver does not use twisted.names unless
339+
you explicitly install twisted.names as the resolver; rather it uses a GAIResolver
340+
backed by the reactor's default threadpool (which is limited to 10 threads). So
341+
(a) I don't understand why twisted ticket 9620 is relevant, and (b) I don't
342+
understand why we would run out of FDs if we did too many lookups at once.
343+
-- richvdh 2020/08/29
337344
"""
338345
new_resolver = _LimitedHostnameResolver(
339346
reactor.nameResolver, max_dns_requests_in_flight

synapse/events/builder.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
15-
from typing import Optional
15+
from typing import Any, Dict, List, Optional, Tuple, Union
1616

1717
import attr
1818
from nacl.signing import SigningKey
@@ -97,14 +97,14 @@ def state_key(self):
9797
def is_state(self):
9898
return self._state_key is not None
9999

100-
async def build(self, prev_event_ids):
100+
async def build(self, prev_event_ids: List[str]) -> EventBase:
101101
"""Transform into a fully signed and hashed event
102102
103103
Args:
104-
prev_event_ids (list[str]): The event IDs to use as the prev events
104+
prev_event_ids: The event IDs to use as the prev events
105105
106106
Returns:
107-
FrozenEvent
107+
The signed and hashed event.
108108
"""
109109

110110
state_ids = await self._state.get_current_state_ids(
@@ -114,8 +114,13 @@ async def build(self, prev_event_ids):
114114

115115
format_version = self.room_version.event_format
116116
if format_version == EventFormatVersions.V1:
117-
auth_events = await self._store.add_event_hashes(auth_ids)
118-
prev_events = await self._store.add_event_hashes(prev_event_ids)
117+
# The types of auth/prev events changes between event versions.
118+
auth_events = await self._store.add_event_hashes(
119+
auth_ids
120+
) # type: Union[List[str], List[Tuple[str, Dict[str, str]]]]
121+
prev_events = await self._store.add_event_hashes(
122+
prev_event_ids
123+
) # type: Union[List[str], List[Tuple[str, Dict[str, str]]]]
119124
else:
120125
auth_events = auth_ids
121126
prev_events = prev_event_ids
@@ -138,7 +143,7 @@ async def build(self, prev_event_ids):
138143
"unsigned": self.unsigned,
139144
"depth": depth,
140145
"prev_state": [],
141-
}
146+
} # type: Dict[str, Any]
142147

143148
if self.is_state():
144149
event_dict["state_key"] = self._state_key

0 commit comments

Comments
 (0)