from heisen.config import settings
from heisen.core.log import logger
from jsonrpclib.request import Connection


def get_rpc_connection():
    servers = {
        'self': [
            ('127.0.0.1', settings.RPC_PORT, 'aliehsanmilad', 'Key1_s!3cr3t')
        ],
    }

    servers.update(getattr(settings, 'RPC_SERVERS', {}))
    return Connection(servers, 'heisen', settings.APP_NAME)


rpc_call = get_rpc_connection()

from heisen.config import settings
from heisen.core.log import logger
from jsonrpclib.request import ConnectionPool


def get_rpc_connection():
    if settings.CREDENTIALS:
        username, passowrd = settings.CREDENTIALS[0]
    else:
        username = passowrd = None

    servers = {'self': [('localhost', settings.RPC_PORT, username, passowrd)]}

    servers.update(getattr(settings, 'RPC_SERVERS', {}))
    return ConnectionPool(servers, 'heisen', settings.APP_NAME)


rpc_call = get_rpc_connection()

Use connection pool for jsonrpc
Use connection pool for jsonrpc
