Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Matrix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Operate
Environments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Matrix
Commits
26d17b9b
Commit
26d17b9b
authored
4 years ago
by
Richard van der Hoff
Browse files
Options
Downloads
Patches
Plain Diff
Make `has_completed_background_updates` async
(Almost) everywhere that uses it is happy with an awaitable.
parent
cfe8c8ab
No related branches found
Branches containing commit
No related tags found
Tags containing commit
Loading
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
synapse/storage/background_updates.py
+3
-4
3 additions, 4 deletions
synapse/storage/background_updates.py
tests/storage/test_background_update.py
+3
-1
3 additions, 1 deletion
tests/storage/test_background_update.py
with
6 additions
and
5 deletions
synapse/storage/background_updates.py
+
3
−
4
View file @
26d17b9b
...
...
@@ -119,12 +119,11 @@ class BackgroundUpdater(object):
self
.
_all_done
=
True
return
None
@defer.inlineCallbacks
def
has_completed_background_updates
(
self
):
async
def
has_completed_background_updates
(
self
)
->
bool
:
"""
Check if all the background updates have completed
Returns:
Deferred[bool]:
True if all background updates have completed
True if all background updates have completed
"""
# if we've previously determined that there is nothing left to do, that
# is easy
...
...
@@ -138,7 +137,7 @@ class BackgroundUpdater(object):
# otherwise, check if there are updates to be run. This is important,
# as we may be running on a worker which doesn't perform the bg updates
# itself, but still wants to wait for them to happen.
updates
=
yield
self
.
db
.
simple_select_onecol
(
updates
=
await
self
.
db
.
simple_select_onecol
(
"
background_updates
"
,
keyvalues
=
None
,
retcol
=
"
1
"
,
...
...
This diff is collapsed.
Click to expand it.
tests/storage/test_background_update.py
+
3
−
1
View file @
26d17b9b
...
...
@@ -11,7 +11,9 @@ class BackgroundUpdateTestCase(unittest.HomeserverTestCase):
def
prepare
(
self
,
reactor
,
clock
,
homeserver
):
self
.
updates
=
self
.
hs
.
get_datastore
().
db
.
updates
# type: BackgroundUpdater
# the base test class should have run the real bg updates for us
self
.
assertTrue
(
self
.
updates
.
has_completed_background_updates
())
self
.
assertTrue
(
self
.
get_success
(
self
.
updates
.
has_completed_background_updates
())
)
self
.
update_handler
=
Mock
()
self
.
updates
.
register_background_update_handler
(
...
...
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