Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Tidy up get current token for writer
Browse files Browse the repository at this point in the history
  • Loading branch information
erikjohnston committed Oct 20, 2023
1 parent 79fb6fe commit c02859c
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions synapse/storage/util/id_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,10 +726,6 @@ def get_current_token_for_writer(self, instance_name: str) -> int:
instance_name, self._persisted_upto_position
)

max_pos = max(
self._current_positions.values(), default=self._persisted_upto_position
)

# We want to return the maximum "current token" that we can for a
# writer, this helps ensure that streams progress as fast as
# possible.
Expand All @@ -743,11 +739,11 @@ def get_current_token_for_writer(self, instance_name: str) -> int:
# For our own instance when there's nothing in flight, it's safe
# to advance to the maximum persisted position we've seen (as we
# know that any new tokens we request will be greater).
max_pos = max(
max_pos_of_all_writers = max(
self._current_positions.values(),
default=self._persisted_upto_position,
)
pos = max(pos, max_pos)
pos = max(pos, max_pos_of_all_writers)

return self._return_factor * pos

Expand Down

0 comments on commit c02859c

Please sign in to comment.