bibajz / bitcoin-python-async-rpc

Minimal Bitcoin JSON-RPC Python asynchronous client
MIT License
31 stars 12 forks source link

Async context manager for BitcoinRPC #7

Closed bibajz closed 3 years ago

bibajz commented 3 years ago

As noted in https://github.com/bibajz/bitcoin-python-async-rpc/issues/6#issuecomment-819139200, remembering to call BitcoinRPC.aclose to close the underlying httpx.AsyncClient feels repetitive and one may forget it.

Implement __aenter__ and __aexit__ coroutines which will handle the closing automatically.

bibajz commented 3 years ago

Resolved in https://github.com/bibajz/bitcoin-python-async-rpc/commit/510ebe42616bb72a0db64e081be94002bc164fdf