def run_subscribe(self): while not self.stopped: try: pool = Pool( PoolClient, dict(name=self.name, server_address=self.master_address)) while True: with pool.connection() as client: client.subscribe(self.name, self.bound_address) gevent.sleep(1.0) except Exception as e: self.logger.exception(str(e)) gevent.sleep(1.0)
def run_put_accounts(self): while not self.stopped: try: pool = Pool(PoolClient, dict(name=self.name, server_address=self.master_address)) while True: accounts = [] for service in ['click', 'nano', 'yjfx']: accounts.append(new_account(service, equity=100)) with pool.connection() as client: client.put_accounts(accounts) gevent.sleep(1.0) except Exception as e: self.logger.exception(str(e)) gevent.sleep(1.0)
def run_put_prices(self): while not self.stopped: try: pool = Pool(PoolClient, dict(name=self.name, server_address=self.master_address)) while True: prices = [] for service in ['click', 'nano', 'yjfx']: for instrument in ['USD/JPY', 'AUD/JPY']: prices.append(dict(service=service, instrument=instrument, bid=100.0, ask=100.0, time=None)) with pool.connection() as client: client.put_prices(prices) gevent.sleep(1.0) except Exception as e: self.logger.exception(str(e)) gevent.sleep(1.0)
def __init__(self, id: str, address: str, status: NodeState = NodeState.Ready, cb: CodecBuilder = None, connect_timeout=5): self.id = id self.address = address self.status = status self._cb = cb pair = address.split(":") options = dict(host=pair[0], port=int(pair[1]), timeout=connect_timeout) self.pool: Pool = Pool(TcpConnection, options, # initial_connections=1, max_connections=default_max_connections, reap_expired_connections=False) self.error_count = 0 self.count = 1
def subscribe(self, name: str, client_address: Tuple[str, int]): self.subscriber_pools[(name, client_address)] = Pool( PoolClient, dict(name=name, server_address=client_address)) self.logger.info('subscribed from {}({})'.format(name, client_address))
def _init_pool(self): return Pool(HttpRpcClient, dict(host=self.ip, port=self._port, ssl=True))
def _init_pool(self): return Pool(TcpRpcClient, dict(host=self.ip, port=self._port))
def _init_pool(self): return Pool(TcpConnection, dict(host=self.ip, port=self._port))