Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RPC connection note closed #76

Open
BeOleg opened this issue Sep 26, 2017 · 0 comments
Open

RPC connection note closed #76

BeOleg opened this issue Sep 26, 2017 · 0 comments

Comments

@BeOleg
Copy link

BeOleg commented Sep 26, 2017

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)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant