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
c88d50aa
Commit
c88d50aa
authored
6 years ago
by
Ivan Shapovalov
Browse files
Options
Downloads
Patches
Plain Diff
federation/send_queue.py: fix usage of sortedcontainers.SortedDict
parent
e316407b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/federation/send_queue.py
+22
-27
22 additions, 27 deletions
synapse/federation/send_queue.py
with
22 additions
and
27 deletions
synapse/federation/send_queue.py
+
22
−
27
View file @
c88d50aa
...
...
@@ -98,7 +98,7 @@ class FederationRemoteSendQueue(object):
now
=
self
.
clock
.
time_msec
()
keys
=
self
.
pos_time
.
keys
()
time
=
keys
.
bisect_left
(
now
-
FIVE_MINUTES_AGO
)
time
=
self
.
pos_time
.
bisect_left
(
now
-
FIVE_MINUTES_AGO
)
if
not
keys
[:
time
]:
return
...
...
@@ -113,7 +113,7 @@ class FederationRemoteSendQueue(object):
with
Measure
(
self
.
clock
,
"
send_queue._clear
"
):
# Delete things out of presence maps
keys
=
self
.
presence_changed
.
keys
()
i
=
keys
.
bisect_left
(
position_to_delete
)
i
=
self
.
presence_changed
.
bisect_left
(
position_to_delete
)
for
key
in
keys
[:
i
]:
del
self
.
presence_changed
[
key
]
...
...
@@ -131,7 +131,7 @@ class FederationRemoteSendQueue(object):
# Delete things out of keyed edus
keys
=
self
.
keyed_edu_changed
.
keys
()
i
=
keys
.
bisect_left
(
position_to_delete
)
i
=
self
.
keyed_edu_changed
.
bisect_left
(
position_to_delete
)
for
key
in
keys
[:
i
]:
del
self
.
keyed_edu_changed
[
key
]
...
...
@@ -145,19 +145,19 @@ class FederationRemoteSendQueue(object):
# Delete things out of edu map
keys
=
self
.
edus
.
keys
()
i
=
key
s
.
bisect_left
(
position_to_delete
)
i
=
self
.
edu
s
.
bisect_left
(
position_to_delete
)
for
key
in
keys
[:
i
]:
del
self
.
edus
[
key
]
# Delete things out of failure map
keys
=
self
.
failures
.
keys
()
i
=
key
s
.
bisect_left
(
position_to_delete
)
i
=
self
.
failure
s
.
bisect_left
(
position_to_delete
)
for
key
in
keys
[:
i
]:
del
self
.
failures
[
key
]
# Delete things out of device map
keys
=
self
.
device_messages
.
keys
()
i
=
key
s
.
bisect_left
(
position_to_delete
)
i
=
self
.
device_message
s
.
bisect_left
(
position_to_delete
)
for
key
in
keys
[:
i
]:
del
self
.
device_messages
[
key
]
...
...
@@ -250,13 +250,12 @@ class FederationRemoteSendQueue(object):
self
.
_clear_queue_before_pos
(
federation_ack
)
# Fetch changed presence
keys
=
self
.
presence_changed
.
keys
()
i
=
keys
.
bisect_right
(
from_token
)
j
=
keys
.
bisect_right
(
to_token
)
+
1
i
=
self
.
presence_changed
.
bisect_right
(
from_token
)
j
=
self
.
presence_changed
.
bisect_right
(
to_token
)
+
1
dest_user_ids
=
[
(
pos
,
user_id
)
for
pos
in
keys
[
i
:
j
]
for
user_id
in
se
lf
.
presence_changed
[
pos
]
for
pos
,
user_id_list
in
self
.
presence_changed
.
items
()
[
i
:
j
]
for
user_id
in
u
se
r_id_list
]
for
(
key
,
user_id
)
in
dest_user_ids
:
...
...
@@ -265,13 +264,12 @@ class FederationRemoteSendQueue(object):
)))
# Fetch changes keyed edus
keys
=
self
.
keyed_edu_changed
.
keys
()
i
=
keys
.
bisect_right
(
from_token
)
j
=
keys
.
bisect_right
(
to_token
)
+
1
i
=
self
.
keyed_edu_changed
.
bisect_right
(
from_token
)
j
=
self
.
keyed_edu_changed
.
bisect_right
(
to_token
)
+
1
# We purposefully clobber based on the key here, python dict comprehensions
# always use the last value, so this will correctly point to the last
# stream position.
keyed_edus
=
{
self
.
keyed_edu_changed
[
k
]:
k
for
k
in
keys
[
i
:
j
]}
keyed_edus
=
{
v
:
k
for
k
,
v
in
self
.
keyed_edu_changed
.
items
()
[
i
:
j
]}
for
((
destination
,
edu_key
),
pos
)
in
iteritems
(
keyed_edus
):
rows
.
append
((
pos
,
KeyedEduRow
(
...
...
@@ -280,19 +278,17 @@ class FederationRemoteSendQueue(object):
)))
# Fetch changed edus
keys
=
self
.
edus
.
keys
()
i
=
keys
.
bisect_right
(
from_token
)
j
=
keys
.
bisect_right
(
to_token
)
+
1
edus
=
((
k
,
self
.
edus
[
k
])
for
k
in
keys
[
i
:
j
])
i
=
self
.
edus
.
bisect_right
(
from_token
)
j
=
self
.
edus
.
bisect_right
(
to_token
)
+
1
edus
=
self
.
edus
.
items
()[
i
:
j
]
for
(
pos
,
edu
)
in
edus
:
rows
.
append
((
pos
,
EduRow
(
edu
)))
# Fetch changed failures
keys
=
self
.
failures
.
keys
()
i
=
keys
.
bisect_right
(
from_token
)
j
=
keys
.
bisect_right
(
to_token
)
+
1
failures
=
((
k
,
self
.
failures
[
k
])
for
k
in
keys
[
i
:
j
])
i
=
self
.
failures
.
bisect_right
(
from_token
)
j
=
self
.
failures
.
bisect_right
(
to_token
)
+
1
failures
=
self
.
failures
.
items
()[
i
:
j
]
for
(
pos
,
(
destination
,
failure
))
in
failures
:
rows
.
append
((
pos
,
FailureRow
(
...
...
@@ -301,10 +297,9 @@ class FederationRemoteSendQueue(object):
)))
# Fetch changed device messages
keys
=
self
.
device_messages
.
keys
()
i
=
keys
.
bisect_right
(
from_token
)
j
=
keys
.
bisect_right
(
to_token
)
+
1
device_messages
=
{
self
.
device_messages
[
k
]:
k
for
k
in
keys
[
i
:
j
]}
i
=
self
.
device_messages
.
bisect_right
(
from_token
)
j
=
self
.
device_messages
.
bisect_right
(
to_token
)
+
1
device_messages
=
{
v
:
k
for
k
,
v
in
self
.
device_messages
.
items
()[
i
:
j
]}
for
(
destination
,
pos
)
in
iteritems
(
device_messages
):
rows
.
append
((
pos
,
DeviceRow
(
...
...
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