This isn't used yet, but it's there as a general mechanism.
Don't rate-limit reconnections provoked by the pinger internally because
(a) these are relatively infrequent anyway by the nature of the pinger
mechanism, and (b) the current rate-limiting strategy is simply to
ignore a reconnection request if we've already made an attempt fairly
recently, so there isn't (and it's not worth building) the necessary
machinery to defer reconnection, and determine whether a deferred
reconnection is still needed.
me._ping()
else:
me._timer = M.SelTimer(now + me._every, me._time)
+ me._last_reconn = now
def update(me, peer):
"""
if me._connectp: T.spawn(run_connect, peer, peer.get('connect'))
me._timer = M.SelTimer(now + me._every, me._time)
me._sabotage = False
+ me._last_reconn = now
else:
S.kill(me._peer)
except T.TripeError, e:
if e.args[0] == 'unknown-peer': me._pinger.kill(me._peer)
+ def reconnect(me):
+ """
+ Attempt reconnection to the peer.
+
+ Applies rate-limiting so that we don't hammer a remote peer just because
+ we notice several problems in a short time interval.
+ """
+ now = time()
+ if now >= me._last_reconn + 5: me._reconnect(now)
+
def event(me, code, stuff):
"""
Respond to an event which happened to this peer.