steemit / tinman

Testnet management scripts
8 stars 20 forks source link

better error handling - while establishing connection #153

Open bobinson opened 6 years ago

bobinson commented 6 years ago

Right now while establishing connection if tinman receives an error from the server like the example, given below, the connection is aborted. While once the connection is establishes we are retrying for MAX_RETRY times. In a similar fashion, if we retry or wait a few seconds based on the error message from the server, that will be helpful.

A useful scenario is when an automated test is run, messages like 'Unable to acquire database lock' can be used to continue trying to start the test using tinman instead of just aborting.


[09:29 PM] bobinson@air 🖖  [~/hack/tinman]python -m tinman snapshot -s https://testnet.steemitdev.com -o snapshot.json
Traceback (most recent call last):
  File "/Users/user/.pyenv/versions/3.6.5/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/Users/user/.pyenv/versions/3.6.5/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/user/hack/tinman/tinman/__main__.py", line 4, in <module>
    main.sys_main()
  File "/Users/user/hack/tinman/tinman/main.py", line 55, in sys_main
    result = main(sys.argv)
  File "/Users/user/hack/tinman/tinman/main.py", line 52, in main
    return module.main(argv[1:])
  File "/Users/user/hack/tinman/tinman/snapshot.py", line 134, in main
    dump_dgpo(steemd, outfile)
  File "/Users/user/hack/tinman/tinman/snapshot.py", line 113, in dump_dgpo
    dgpo = steemd.database_api.get_dynamic_global_properties(x=None)
  File "/Users/b5413b/hack/tinman/simple_steem_client/client.py", line 225, in __call__
    method_kwargs=kwargs,
  File "/Users/user/hack/tinman/simple_steem_client/client.py", line 179, in rpc_call
    raise SteemRPCException(resp)
simple_steem_client.client.SteemRPCException: OrderedDict([('jsonrpc', '2.0'), ('error', OrderedDict([('code', -32003), ('message', 'Unable to acquire database lock')])), ('id', 0)])
inertia186 commented 6 years ago

The problem here is that the retry logic is consentrated in snapshot.list_all_accounts. A more comprehensive approach would be to place the retry logic in simple_steem_client. But then the simple client wouldn't be quite as simple.

I would actually prefer to generalize the retry logic in tinman (without excessive boiler plate).

bobinson commented 6 years ago

I would actually prefer to generalize the retry logic in tinman (without excessive boiler plate).

agree.

relativityboy commented 6 years ago

@bobinson - is that something you'd be interested in working on? We could create an issue with some very clear acceptance criteria.

bobinson commented 6 years ago

@relativityboy - yes, I will be interested in giving it a try