Require aiorpcx 0.9.x

This commit is contained in:
Neil Booth 2018-10-26 09:17:17 -04:00
parent 06d58f7786
commit eba718c6de
5 changed files with 15 additions and 15 deletions

View File

@ -1,4 +1,4 @@
# Copyright (c) 2016-2017, Neil Booth # Copyright (c) 2016-2018, Neil Booth
# #
# All rights reserved. # All rights reserved.
# #
@ -83,8 +83,8 @@ class Controller(ServerBase):
'''Start the RPC server and wait for the mempool to synchronize. Then '''Start the RPC server and wait for the mempool to synchronize. Then
start serving external clients. start serving external clients.
''' '''
if not (0, 8, 1) <= aiorpcx_version < (0, 9): if not (0, 9, 0) <= aiorpcx_version < (0, 10):
raise RuntimeError('aiorpcX version 0.8.x with x >= 1 required') raise RuntimeError('aiorpcX version 0.9.x required')
env = self.env env = self.env
min_str, max_str = env.coin.SESSIONCLS.protocol_min_max_strings() min_str, max_str = env.coin.SESSIONCLS.protocol_min_max_strings()

View File

@ -1,4 +1,4 @@
# Copyright (c) 2017, Neil Booth # Copyright (c) 2017-2018, Neil Booth
# #
# All rights reserved. # All rights reserved.
# #
@ -14,7 +14,7 @@ import ssl
import time import time
from collections import defaultdict, Counter from collections import defaultdict, Counter
from aiorpcx import (ClientSession, SOCKSProxy, from aiorpcx import (Connector, RPCSession, SOCKSProxy,
Notification, handler_invocation, Notification, handler_invocation,
SOCKSError, RPCError, TaskTimeout, TaskGroup, Event, SOCKSError, RPCError, TaskTimeout, TaskGroup, Event,
sleep, run_in_thread, ignore_after, timeout_after) sleep, run_in_thread, ignore_after, timeout_after)
@ -37,7 +37,7 @@ def assert_good(message, result, instance):
f'{type(result).__name__}') f'{type(result).__name__}')
class PeerSession(ClientSession): class PeerSession(RPCSession):
'''An outgoing session to a peer.''' '''An outgoing session to a peer.'''
async def handle_request(self, request): async def handle_request(self, request):
@ -226,8 +226,8 @@ class PeerManager(object):
peer_text = f'[{peer}:{port} {kind}]' peer_text = f'[{peer}:{port} {kind}]'
try: try:
async with timeout_after(120 if peer.is_tor else 30): async with timeout_after(120 if peer.is_tor else 30):
async with PeerSession(peer.host, port, async with Connector(PeerSession, peer.host, port,
**kwargs) as session: **kwargs) as session:
await self._verify_peer(session, peer) await self._verify_peer(session, peer)
is_good = True is_good = True
break break

View File

@ -20,7 +20,7 @@ from collections import defaultdict
from functools import partial from functools import partial
from aiorpcx import ( from aiorpcx import (
ServerSession, JSONRPCAutoDetect, JSONRPCConnection, RPCSession, JSONRPCAutoDetect, JSONRPCConnection,
TaskGroup, handler_invocation, RPCError, Request, ignore_after, sleep, TaskGroup, handler_invocation, RPCError, Request, ignore_after, sleep,
Event Event
) )
@ -289,7 +289,7 @@ class SessionManager(object):
'errors': sum(s.errors for s in self.sessions), 'errors': sum(s.errors for s in self.sessions),
'groups': len(group_map), 'groups': len(group_map),
'logged': len([s for s in self.sessions if s.log_me]), 'logged': len([s for s in self.sessions if s.log_me]),
'paused': sum(s.paused for s in self.sessions), 'paused': sum(not s.can_send.is_set() for s in self.sessions),
'pid': os.getpid(), 'pid': os.getpid(),
'peers': self.peer_mgr.info(), 'peers': self.peer_mgr.info(),
'requests': sum(s.count_pending_items() for s in self.sessions), 'requests': sum(s.count_pending_items() for s in self.sessions),
@ -593,7 +593,7 @@ class SessionManager(object):
self.subs_room -= 1 self.subs_room -= 1
class SessionBase(ServerSession): class SessionBase(RPCSession):
'''Base class of ElectrumX JSON sessions. '''Base class of ElectrumX JSON sessions.
Each session runs its tasks in asynchronous parallelism with other Each session runs its tasks in asynchronous parallelism with other
@ -667,7 +667,7 @@ class SessionBase(ServerSession):
super().connection_lost(exc) super().connection_lost(exc)
self.session_mgr.remove_session(self) self.session_mgr.remove_session(self)
msg = '' msg = ''
if self.paused: if not self.can_send.is_set():
msg += ' whilst paused' msg += ' whilst paused'
if self.concurrency.max_concurrent != self.max_concurrent: if self.concurrency.max_concurrent != self.max_concurrent:
msg += ' whilst throttled' msg += ' whilst throttled'

View File

@ -10,7 +10,7 @@
'''Script to send RPC commands to a running ElectrumX server.''' '''Script to send RPC commands to a running ElectrumX server.'''
from aiorpcx import timeout_after, ClientSession, TaskTimeout from aiorpcx import timeout_after, Connector, RPCSession, TaskTimeout
import argparse import argparse
import asyncio import asyncio
import json import json
@ -114,7 +114,7 @@ def main():
async def send_request(): async def send_request():
try: try:
async with timeout_after(15): async with timeout_after(15):
async with ClientSession('localhost', port) as session: async with Connector(RPCSession, 'localhost', port) as session:
result = await session.send_request(method, args) result = await session.send_request(method, args)
if method in ('query', ): if method in ('query', ):
for line in result: for line in result:

View File

@ -12,7 +12,7 @@ setuptools.setup(
# "blake256" package is required to sync Decred network. # "blake256" package is required to sync Decred network.
# "xevan_hash" package is required to sync Xuez network. # "xevan_hash" package is required to sync Xuez network.
# "groestlcoin_hash" package is required to sync Groestlcoin network. # "groestlcoin_hash" package is required to sync Groestlcoin network.
install_requires=['aiorpcX>=0.8.1,<0.9', 'attrs', install_requires=['aiorpcX>=0.9.0,<0.10', 'attrs',
'plyvel', 'pylru', 'aiohttp >= 2'], 'plyvel', 'pylru', 'aiohttp >= 2'],
packages=setuptools.find_packages(include=('electrumx*',)), packages=setuptools.find_packages(include=('electrumx*',)),
description='ElectrumX Server', description='ElectrumX Server',