def __init__(self, *, framer=None, loop=None): self.framer = framer or self.default_framer() self.loop = loop or asyncio.get_event_loop() self.logger = logging.getLogger(self.__class__.__name__) self.transport = None self.closed_event = self.event() # Set when a connection is made self._address = None self._proxy_address = None # For logger.debug messsages self.verbosity = 0 # Cleared when the send socket is full self._can_send = self.event() self._can_send.set() self._task_group = TaskGroup() # Force-close a connection if a send doesn't succeed in this time self.max_send_delay = 60 # Statistics. The RPC object also keeps its own statistics. self.start_time = time.time() self.errors = 0 self.send_count = 0 self.send_size = 0 self.last_send = self.start_time self.recv_count = 0 self.recv_size = 0 self.last_recv = self.start_time # Bandwidth usage per hour before throttling starts self.bw_limit = 2000000 self.bw_time = self.start_time self.bw_charge = 0 # Concurrency control self.max_concurrent = 6 self._concurrency = Concurrency(self.max_concurrent)
def __init__(self, transport, *, loop=None): self.transport = transport self.loop = loop or asyncio.get_event_loop() self.logger = logging.getLogger(self.__class__.__name__) # For logger.debug messsages self.verbosity = 0 self._group = TaskGroup() # Statistics. The RPC object also keeps its own statistics. self.start_time = time.time() self.errors = 0 self.send_count = 0 self.send_size = 0 self.last_send = self.start_time self.recv_count = 0 self.recv_size = 0 self.last_recv = self.start_time # Resource usage self.cost = 0.0 self._cost_last = 0.0 self._cost_time = self.start_time self._cost_fraction = 0.0 # Concurrency control for incoming request handling self._incoming_concurrency = Concurrency(self.initial_concurrent) # By default, do not limit outgoing connections if self.session_kind == SessionKind.CLIENT: self.cost_hard_limit = 0
def __init__(self, *, framer=None, loop=None): self.framer = framer or self.default_framer() self.loop = loop or asyncio.get_event_loop() self.logger = logging.getLogger(self.__class__.__name__) self.transport = None self.closed_event = self.event() # Set when a connection is made self._address = None self._proxy_address = None # For logger.debug messsages self.verbosity = 0 # Cleared when the send socket is full self._can_send = self.event() self._can_send.set() self._task = None self._group = TaskGroup() # Statistics. The RPC object also keeps its own statistics. self.start_time = time.time() self.errors = 0 self.send_count = 0 self.send_size = 0 self.last_send = self.start_time self.recv_count = 0 self.recv_size = 0 self.last_recv = self.start_time # Resource usage self.cost = 0.0 self._cost_last = 0.0 self._cost_time = self.start_time self._cost_fraction = 0.0 # Concurrency control for incoming request handling self._incoming_concurrency = Concurrency(self.initial_concurrent)
async def query_all_exchanges_for_their_ccys_over_network(): async with timeout_after(10): async with TaskGroup() as group: for name, klass in exchanges.items(): exchange = klass(None, None) await group.spawn(get_currencies_safe(name, exchange))