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
ef276e87
Commit
ef276e87
authored
10 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Fix so timing out connections to actually work.
parent
41a9a76a
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/federation/replication.py
+2
-0
2 additions, 0 deletions
synapse/federation/replication.py
synapse/util/__init__.py
+43
-9
43 additions, 9 deletions
synapse/util/__init__.py
with
45 additions
and
9 deletions
synapse/federation/replication.py
+
2
−
0
View file @
ef276e87
...
...
@@ -72,5 +72,7 @@ class ReplicationLayer(FederationClient, FederationServer):
self
.
_order
=
0
self
.
hs
=
hs
def
__str__
(
self
):
return
"
<ReplicationLayer(%s)>
"
%
self
.
server_name
This diff is collapsed.
Click to expand it.
synapse/util/__init__.py
+
43
−
9
View file @
ef276e87
...
...
@@ -18,6 +18,9 @@ from synapse.util.logcontext import LoggingContext
from
twisted.internet
import
defer
,
reactor
,
task
import
time
import
logging
logger
=
logging
.
getLogger
(
__name__
)
class
Clock
(
object
):
...
...
@@ -55,20 +58,51 @@ class Clock(object):
timer
.
cancel
()
def
time_bound_deferred
(
self
,
given_deferred
,
time_out
):
if
given_deferred
.
called
:
return
given_deferred
ret_deferred
=
defer
.
Deferred
()
def
timed_out
():
if
not
given_deferred
.
called
:
given_deferred
.
cancel
()
def
timed_out_fn
():
try
:
ret_deferred
.
errback
(
RuntimeError
(
"
Timed out
"
))
except
:
pass
try
:
given_deferred
.
cancel
()
except
:
pass
timer
=
None
def
cancel
(
res
):
try
:
self
.
cancel_call_later
(
timer
)
except
:
pass
return
res
ret_deferred
.
addBoth
(
cancel
)
def
sucess
(
res
):
try
:
ret_deferred
.
callback
(
res
)
except
:
pass
return
res
def
err
(
res
):
try
:
ret_deferred
.
errback
(
res
)
except
:
pass
timer
=
self
.
call_later
(
time_out
,
timed_out
)
return
res
def
succeed
(
result
):
self
.
cancel_call_later
(
timer
)
ret_deferred
.
callback
(
result
)
given_deferred
.
addCallbacks
(
callback
=
sucess
,
errback
=
err
)
given_deferred
.
addCallback
(
succeed
)
given_deferred
.
addErrback
(
ret_deferred
.
errback
)
timer
=
self
.
call_later
(
time_out
,
timed_out_fn
)
return
ret_deferred
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