jgarzik / jgarzik/python-bitcoinrpc

RPC connection note closed

Aperta
#76 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Python
Stelle
663
Fork
300
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Hi, I have many threads in my wallet after using your code.
Is it possible to call `connection.close` somewhere?
Or should I use the more pythonic `with`?

My code is as follows:

```
class BaseRpcClient(BaseApiClient):

def __init__(self):
super(BaseRpcClient, self).__init__()
self.api_cache = {}
self.rpc_endpoint = None

def get_api(self, node):
self.rpc_endpoint = RpcMapper.get_rpc_addr(node)
if self.rpc_endpoint not in self.api_cache:
self.api_cache[self.rpc_endpoint] = \
AuthServiceProxy(self.rpc_endpoint)
self.api = self.api_cache[self.rpc_endpoint]
return self.api

def call_api(self, node, endpoint, *args):
api = self.get_api(node)
try:
fn = getattr(api, endpoint)
return fn(*args)
except JSONRPCException as e:
self.logger.error('JSON RPC ERROR HOST {} ERROR {}'
.format(self.rpc_endpoint, str(e)))
```

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.