Browse Source

interface: log: silence some tracebacks

```
191.73 | D | i/interface.[btc.electroncash.dk:60002] | (disconnect) trace for RPCError(-32603, 'internal error: bitcoind request timed out')
Traceback (most recent call last):
  File "...\electrum\electrum\interface.py", line 514, in wrapper_func
    return await func(self, *args, **kwargs)
  File "...\electrum\electrum\interface.py", line 537, in run
    await self.open_session(ssl_context)
  File "...\electrum\electrum\interface.py", line 687, in open_session
    async with self.taskgroup as group:
  File "...\aiorpcX\aiorpcx\curio.py", line 304, in __aexit__
    await self.join()
  File "...\electrum\electrum\util.py", line 1309, in join
    task.result()
  File "...\electrum\electrum\interface.py", line 724, in request_fee_estimates
    async with OldTaskGroup() as group:
  File "...\aiorpcX\aiorpcx\curio.py", line 304, in __aexit__
    await self.join()
  File "...\electrum\electrum\util.py", line 1309, in join
    task.result()
  File "...\electrum\electrum\interface.py", line 1128, in get_estimatefee
    res = await self.session.send_request('blockchain.estimatefee', [num_blocks])
  File "...\electrum\electrum\interface.py", line 169, in send_request
    response = await util.wait_for2(
  File "...\electrum\electrum\util.py", line 1383, in wait_for2
    return await asyncio.ensure_future(fut, loop=get_running_loop())
  File "...\aiorpcX\aiorpcx\session.py", line 540, in send_request
    return await self._send_concurrent(message, future, 1)
  File "...\aiorpcX\aiorpcx\session.py", line 512, in _send_concurrent
    return await future
aiorpcx.jsonrpc.RPCError: (-32603, 'internal error: bitcoind request timed out')
```

```
 93.60 | E | asyncio | Task exception was never retrieved
future: <Task finished name='Task-7385' coro=<Interface.get_estimatefee() done, defined at ...\electrum\electrum\interface.py:1123> exception=RPCError(-32603, 'internal error: bitcoind request timed out')>
Traceback (most recent call last):
  File "...\electrum\electrum\interface.py", line 1132, in get_estimatefee
    res = await self.session.send_request('blockchain.estimatefee', [num_blocks])
  File "...\electrum\electrum\interface.py", line 169, in send_request
    response = await util.wait_for2(
  File "...\electrum\electrum\util.py", line 1383, in wait_for2
    return await asyncio.ensure_future(fut, loop=get_running_loop())
  File "...\aiorpcX\aiorpcx\session.py", line 540, in send_request
    return await self._send_concurrent(message, future, 1)
  File "...\aiorpcX\aiorpcx\session.py", line 512, in _send_concurrent
    return await future
aiorpcx.jsonrpc.RPCError: (-32603, 'internal error: bitcoind request timed out')
```
master
SomberNight 2 years ago
parent
commit
8931420938
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
  1. 22
      electrum/interface.py

22
electrum/interface.py

@ -690,10 +690,14 @@ class Interface(Logger):
await group.spawn(self.run_fetch_blocks)
await group.spawn(self.monitor_connection)
except aiorpcx.jsonrpc.RPCError as e:
if e.code in (JSONRPC.EXCESSIVE_RESOURCE_USAGE,
JSONRPC.SERVER_BUSY,
JSONRPC.METHOD_NOT_FOUND):
raise GracefulDisconnect(e, log_level=logging.WARNING) from e
if e.code in (
JSONRPC.EXCESSIVE_RESOURCE_USAGE,
JSONRPC.SERVER_BUSY,
JSONRPC.METHOD_NOT_FOUND,
JSONRPC.INTERNAL_ERROR,
):
log_level = logging.WARNING if self.is_main_server() else logging.INFO
raise GracefulDisconnect(e, log_level=log_level) from e
raise
finally:
self.got_disconnected.set() # set this ASAP, ideally before any awaits
@ -1128,12 +1132,20 @@ class Interface(Logger):
res = await self.session.send_request('blockchain.estimatefee', [num_blocks])
except aiorpcx.jsonrpc.ProtocolError as e:
# The protocol spec says the server itself should already have returned -1
# if it cannot provide an estimate, however apparently electrs does not conform
# if it cannot provide an estimate, however apparently "electrs" does not conform
# and sends an error instead. Convert it here:
if "cannot estimate fee" in e.message:
res = -1
else:
raise
except aiorpcx.jsonrpc.RPCError as e:
# The protocol spec says the server itself should already have returned -1
# if it cannot provide an estimate. "Fulcrum" often sends:
# aiorpcx.jsonrpc.RPCError: (-32603, 'internal error: bitcoind request timed out')
if e.code == JSONRPC.INTERNAL_ERROR:
res = -1
else:
raise
# check response
if res != -1:
assert_non_negative_int_or_float(res)

Loading…
Cancel
Save