Skip to content

Commit 994d7ae

Browse files
committed
Remove broken use of clock.call_later
background_updates was using `call_later` in a way that leaked the logcontext into the reactor. We could have rewritten it to do it properly, but given that we weren't using the fancier facilities provided by `call_later`, we might as well just use `async.sleep`, which does the logcontext stuff properly.
1 parent 2abe85d commit 994d7ae

1 file changed

Lines changed: 3 additions & 12 deletions

File tree

synapse/storage/background_updates.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +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+
import synapse.util.async
1516

1617
from ._base import SQLBaseStore
1718
from . import engines
@@ -84,24 +85,14 @@ def __init__(self, hs):
8485
self._background_update_performance = {}
8586
self._background_update_queue = []
8687
self._background_update_handlers = {}
87-
self._background_update_timer = None
8888

8989
@defer.inlineCallbacks
9090
def start_doing_background_updates(self):
91-
assert self._background_update_timer is None, \
92-
"background updates already running"
93-
9491
logger.info("Starting background schema updates")
9592

9693
while True:
97-
sleep = defer.Deferred()
98-
self._background_update_timer = self._clock.call_later(
99-
self.BACKGROUND_UPDATE_INTERVAL_MS / 1000., sleep.callback, None
100-
)
101-
try:
102-
yield sleep
103-
finally:
104-
self._background_update_timer = None
94+
yield synapse.util.async.sleep(
95+
self.BACKGROUND_UPDATE_INTERVAL_MS / 1000.)
10596

10697
try:
10798
result = yield self.do_next_background_update(

0 commit comments

Comments
 (0)