Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
87972f07
Unverified
Commit
87972f07
authored
5 years ago
by
Patrick Cloke
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Convert remote key resource REST layer to async/await. (#7020)
parent
78a15b1f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
changelog.d/7020.misc
+1
-0
1 addition, 0 deletions
changelog.d/7020.misc
synapse/rest/key/v2/remote_key_resource.py
+4
-7
4 additions, 7 deletions
synapse/rest/key/v2/remote_key_resource.py
with
5 additions
and
7 deletions
changelog.d/7020.misc
0 → 100644
+
1
−
0
View file @
87972f07
Port `synapse.rest.keys` to async/await.
This diff is collapsed.
Click to expand it.
synapse/rest/key/v2/remote_key_resource.py
+
4
−
7
View file @
87972f07
...
@@ -18,8 +18,6 @@ from typing import Dict, Set
...
@@ -18,8 +18,6 @@ from typing import Dict, Set
from
canonicaljson
import
encode_canonical_json
,
json
from
canonicaljson
import
encode_canonical_json
,
json
from
signedjson.sign
import
sign_json
from
signedjson.sign
import
sign_json
from
twisted.internet
import
defer
from
synapse.api.errors
import
Codes
,
SynapseError
from
synapse.api.errors
import
Codes
,
SynapseError
from
synapse.crypto.keyring
import
ServerKeyFetcher
from
synapse.crypto.keyring
import
ServerKeyFetcher
from
synapse.http.server
import
(
from
synapse.http.server
import
(
...
@@ -125,8 +123,7 @@ class RemoteKey(DirectServeResource):
...
@@ -125,8 +123,7 @@ class RemoteKey(DirectServeResource):
await
self
.
query_keys
(
request
,
query
,
query_remote_on_cache_miss
=
True
)
await
self
.
query_keys
(
request
,
query
,
query_remote_on_cache_miss
=
True
)
@defer.inlineCallbacks
async
def
query_keys
(
self
,
request
,
query
,
query_remote_on_cache_miss
=
False
):
def
query_keys
(
self
,
request
,
query
,
query_remote_on_cache_miss
=
False
):
logger
.
info
(
"
Handling query for keys %r
"
,
query
)
logger
.
info
(
"
Handling query for keys %r
"
,
query
)
store_queries
=
[]
store_queries
=
[]
...
@@ -143,7 +140,7 @@ class RemoteKey(DirectServeResource):
...
@@ -143,7 +140,7 @@ class RemoteKey(DirectServeResource):
for
key_id
in
key_ids
:
for
key_id
in
key_ids
:
store_queries
.
append
((
server_name
,
key_id
,
None
))
store_queries
.
append
((
server_name
,
key_id
,
None
))
cached
=
yield
self
.
store
.
get_server_keys_json
(
store_queries
)
cached
=
await
self
.
store
.
get_server_keys_json
(
store_queries
)
json_results
=
set
()
json_results
=
set
()
...
@@ -215,8 +212,8 @@ class RemoteKey(DirectServeResource):
...
@@ -215,8 +212,8 @@ class RemoteKey(DirectServeResource):
json_results
.
add
(
bytes
(
result
[
"
key_json
"
]))
json_results
.
add
(
bytes
(
result
[
"
key_json
"
]))
if
cache_misses
and
query_remote_on_cache_miss
:
if
cache_misses
and
query_remote_on_cache_miss
:
yield
self
.
fetcher
.
get_keys
(
cache_misses
)
await
self
.
fetcher
.
get_keys
(
cache_misses
)
yield
self
.
query_keys
(
request
,
query
,
query_remote_on_cache_miss
=
False
)
await
self
.
query_keys
(
request
,
query
,
query_remote_on_cache_miss
=
False
)
else
:
else
:
signed_keys
=
[]
signed_keys
=
[]
for
key_json
in
json_results
:
for
key_json
in
json_results
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment