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
cfe8c8ab
Commit
cfe8c8ab
authored
4 years ago
by
Richard van der Hoff
Browse files
Options
Downloads
Patches
Plain Diff
Remove unused `start_background_update`
This was only used in a unit test, so let's just inline it in the test.
parent
60adcbed
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
synapse/storage/background_updates.py
+0
-21
0 additions, 21 deletions
synapse/storage/background_updates.py
tests/storage/test_background_update.py
+9
-5
9 additions, 5 deletions
tests/storage/test_background_update.py
with
9 additions
and
26 deletions
synapse/storage/background_updates.py
+
0
−
21
View file @
cfe8c8ab
...
@@ -400,27 +400,6 @@ class BackgroundUpdater(object):
...
@@ -400,27 +400,6 @@ class BackgroundUpdater(object):
self
.
register_background_update_handler
(
update_name
,
updater
)
self
.
register_background_update_handler
(
update_name
,
updater
)
def
start_background_update
(
self
,
update_name
,
progress
):
"""
Starts a background update running.
Args:
update_name: The update to set running.
progress: The initial state of the progress of the update.
Returns:
A deferred that completes once the task has been added to the
queue.
"""
# Clear the background update queue so that we will pick up the new
# task on the next iteration of do_background_update.
self
.
_background_update_queue
=
[]
progress_json
=
json
.
dumps
(
progress
)
return
self
.
db
.
simple_insert
(
"
background_updates
"
,
{
"
update_name
"
:
update_name
,
"
progress_json
"
:
progress_json
},
)
def
_end_background_update
(
self
,
update_name
):
def
_end_background_update
(
self
,
update_name
):
"""
Removes a completed background update task from the queue.
"""
Removes a completed background update task from the queue.
...
...
This diff is collapsed.
Click to expand it.
tests/storage/test_background_update.py
+
9
−
5
View file @
cfe8c8ab
...
@@ -25,12 +25,20 @@ class BackgroundUpdateTestCase(unittest.HomeserverTestCase):
...
@@ -25,12 +25,20 @@ class BackgroundUpdateTestCase(unittest.HomeserverTestCase):
# the target runtime for each bg update
# the target runtime for each bg update
target_background_update_duration_ms
=
50000
target_background_update_duration_ms
=
50000
store
=
self
.
hs
.
get_datastore
()
self
.
get_success
(
store
.
db
.
simple_insert
(
"
background_updates
"
,
values
=
{
"
update_name
"
:
"
test_update
"
,
"
progress_json
"
:
'
{
"
my_key
"
: 1}
'
},
)
)
# first step: make a bit of progress
# first step: make a bit of progress
@defer.inlineCallbacks
@defer.inlineCallbacks
def
update
(
progress
,
count
):
def
update
(
progress
,
count
):
yield
self
.
clock
.
sleep
((
count
*
duration_ms
)
/
1000
)
yield
self
.
clock
.
sleep
((
count
*
duration_ms
)
/
1000
)
progress
=
{
"
my_key
"
:
progress
[
"
my_key
"
]
+
1
}
progress
=
{
"
my_key
"
:
progress
[
"
my_key
"
]
+
1
}
yield
self
.
hs
.
get_data
store
()
.
db
.
runInteraction
(
yield
store
.
db
.
runInteraction
(
"
update_progress
"
,
"
update_progress
"
,
self
.
updates
.
_background_update_progress_txn
,
self
.
updates
.
_background_update_progress_txn
,
"
test_update
"
,
"
test_update
"
,
...
@@ -39,10 +47,6 @@ class BackgroundUpdateTestCase(unittest.HomeserverTestCase):
...
@@ -39,10 +47,6 @@ class BackgroundUpdateTestCase(unittest.HomeserverTestCase):
return
count
return
count
self
.
update_handler
.
side_effect
=
update
self
.
update_handler
.
side_effect
=
update
self
.
get_success
(
self
.
updates
.
start_background_update
(
"
test_update
"
,
{
"
my_key
"
:
1
})
)
self
.
update_handler
.
reset_mock
()
self
.
update_handler
.
reset_mock
()
res
=
self
.
get_success
(
res
=
self
.
get_success
(
self
.
updates
.
do_next_background_update
(
self
.
updates
.
do_next_background_update
(
...
...
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