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
Package registry
Container registry
Model registry
Operate
Terraform modules
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
Timo Ley
synapse
Commits
d250521c
Unverified
Commit
d250521c
authored
4 years ago
by
Patrick Cloke
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Convert the main methods run by the reactor to async. (#8213)
parent
abeab964
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
changelog.d/8213.misc
+1
-0
1 addition, 0 deletions
changelog.d/8213.misc
synapse/app/admin_cmd.py
+9
-11
9 additions, 11 deletions
synapse/app/admin_cmd.py
synapse/app/homeserver.py
+8
-10
8 additions, 10 deletions
synapse/app/homeserver.py
with
18 additions
and
21 deletions
changelog.d/8213.misc
0 → 100644
+
1
−
0
View file @
d250521c
Convert various parts of the codebase to async/await.
This diff is collapsed.
Click to expand it.
synapse/app/admin_cmd.py
+
9
−
11
View file @
d250521c
...
@@ -79,8 +79,7 @@ class AdminCmdServer(HomeServer):
...
@@ -79,8 +79,7 @@ class AdminCmdServer(HomeServer):
pass
pass
@defer.inlineCallbacks
async
def
export_data_command
(
hs
,
args
):
def
export_data_command
(
hs
,
args
):
"""
Export data for a user.
"""
Export data for a user.
Args:
Args:
...
@@ -91,10 +90,8 @@ def export_data_command(hs, args):
...
@@ -91,10 +90,8 @@ def export_data_command(hs, args):
user_id
=
args
.
user_id
user_id
=
args
.
user_id
directory
=
args
.
output_directory
directory
=
args
.
output_directory
res
=
yield
defer
.
ensureDeferred
(
res
=
await
hs
.
get_handlers
().
admin_handler
.
export_user_data
(
hs
.
get_handlers
().
admin_handler
.
export_user_data
(
user_id
,
FileExfiltrationWriter
(
user_id
,
directory
=
directory
)
user_id
,
FileExfiltrationWriter
(
user_id
,
directory
=
directory
)
)
)
)
print
(
res
)
print
(
res
)
...
@@ -232,14 +229,15 @@ def start(config_options):
...
@@ -232,14 +229,15 @@ def start(config_options):
# We also make sure that `_base.start` gets run before we actually run the
# We also make sure that `_base.start` gets run before we actually run the
# command.
# command.
@defer.inlineCallbacks
async
def
run
():
def
run
(
_reactor
):
with
LoggingContext
(
"
command
"
):
with
LoggingContext
(
"
command
"
):
yield
_base
.
start
(
ss
,
[])
_base
.
start
(
ss
,
[])
yield
args
.
func
(
ss
,
args
)
await
args
.
func
(
ss
,
args
)
_base
.
start_worker_reactor
(
_base
.
start_worker_reactor
(
"
synapse-admin-cmd
"
,
config
,
run_command
=
lambda
:
task
.
react
(
run
)
"
synapse-admin-cmd
"
,
config
,
run_command
=
lambda
:
task
.
react
(
lambda
_reactor
:
defer
.
ensureDeferred
(
run
())),
)
)
...
...
This diff is collapsed.
Click to expand it.
synapse/app/homeserver.py
+
8
−
10
View file @
d250521c
...
@@ -411,26 +411,24 @@ def setup(config_options):
...
@@ -411,26 +411,24 @@ def setup(config_options):
return
provision
return
provision
@defer.inlineCallbacks
async
def
reprovision_acme
():
def
reprovision_acme
():
"""
"""
Provision a certificate from ACME, if required, and reload the TLS
Provision a certificate from ACME, if required, and reload the TLS
certificate if it
'
s renewed.
certificate if it
'
s renewed.
"""
"""
reprovisioned
=
yield
defer
.
ensureDeferred
(
do_acme
()
)
reprovisioned
=
await
do_acme
()
if
reprovisioned
:
if
reprovisioned
:
_base
.
refresh_certificate
(
hs
)
_base
.
refresh_certificate
(
hs
)
@defer.inlineCallbacks
async
def
start
():
def
start
():
try
:
try
:
# Run the ACME provisioning code, if it's enabled.
# Run the ACME provisioning code, if it's enabled.
if
hs
.
config
.
acme_enabled
:
if
hs
.
config
.
acme_enabled
:
acme
=
hs
.
get_acme_handler
()
acme
=
hs
.
get_acme_handler
()
# Start up the webservices which we will respond to ACME
# Start up the webservices which we will respond to ACME
# challenges with, and then provision.
# challenges with, and then provision.
yield
defer
.
ensureDeferred
(
acme
.
start_listening
()
)
await
acme
.
start_listening
()
yield
defer
.
ensureDeferred
(
do_acme
()
)
await
do_acme
()
# Check if it needs to be reprovisioned every day.
# Check if it needs to be reprovisioned every day.
hs
.
get_clock
().
looping_call
(
reprovision_acme
,
24
*
60
*
60
*
1000
)
hs
.
get_clock
().
looping_call
(
reprovision_acme
,
24
*
60
*
60
*
1000
)
...
@@ -439,8 +437,8 @@ def setup(config_options):
...
@@ -439,8 +437,8 @@ def setup(config_options):
if
hs
.
config
.
oidc_enabled
:
if
hs
.
config
.
oidc_enabled
:
oidc
=
hs
.
get_oidc_handler
()
oidc
=
hs
.
get_oidc_handler
()
# Loading the provider metadata also ensures the provider config is valid.
# Loading the provider metadata also ensures the provider config is valid.
yield
defer
.
ensureDeferred
(
oidc
.
load_metadata
()
)
await
oidc
.
load_metadata
()
yield
defer
.
ensureDeferred
(
oidc
.
load_jwks
()
)
await
oidc
.
load_jwks
()
_base
.
start
(
hs
,
config
.
listeners
)
_base
.
start
(
hs
,
config
.
listeners
)
...
@@ -456,7 +454,7 @@ def setup(config_options):
...
@@ -456,7 +454,7 @@ def setup(config_options):
reactor
.
stop
()
reactor
.
stop
()
sys
.
exit
(
1
)
sys
.
exit
(
1
)
reactor
.
callWhenRunning
(
start
)
reactor
.
callWhenRunning
(
lambda
:
defer
.
ensureDeferred
(
start
())
)
return
hs
return
hs
...
...
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