This commit is contained in:
Jack Robison 2019-08-20 15:26:00 -04:00
parent c590954eb9
commit 89e395b5f4
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2

View file

@ -2,7 +2,7 @@ import logging
import asyncio import asyncio
from operator import itemgetter from operator import itemgetter
from typing import Dict, Optional, Tuple from typing import Dict, Optional, Tuple
from time import time, perf_counter from time import perf_counter
from torba.rpc import RPCSession as BaseClientSession, Connector, RPCError from torba.rpc import RPCSession as BaseClientSession, Connector, RPCError
@ -60,7 +60,8 @@ class ClientSession(BaseClientSession):
super().send_request(method, args), timeout=self.timeout super().send_request(method, args), timeout=self.timeout
) )
except RPCError as e: except RPCError as e:
log.warning("Wallet server (%s:%i) returned an error. Code: %s Message: %s", *self.server, *e.args) log.warning("Wallet server (%s:%i) returned an error. Code: %s Message: %s",
*self.server, *e.args)
raise e raise e
finally: finally:
self.pending_amount -= 1 self.pending_amount -= 1
@ -257,7 +258,7 @@ class SessionPool:
self.sessions.pop(session).cancel() self.sessions.pop(session).cancel()
session.synchronous_close() session.synchronous_close()
log.info("wallet server %s resolves to the same server as %s, rechecking in an hour", log.info("wallet server %s resolves to the same server as %s, rechecking in an hour",
session.server[0], already_connected.server[0]) session.server[0], already_connected.server[0])
loop.call_later(3600, self._connect_session, session.server) loop.call_later(3600, self._connect_session, session.server)
return return
self.new_connection_event.set() self.new_connection_event.set()
@ -290,7 +291,7 @@ class SessionPool:
self.sessions.clear() self.sessions.clear()
def ensure_connections(self): def ensure_connections(self):
for session, task in list(self.sessions.items()): for session in self.sessions:
self._connect_session(session.server) self._connect_session(session.server)
def trigger_nodelay_connect(self): def trigger_nodelay_connect(self):