Using NamedPipeSite(aiohttp, not committed)

This commit is contained in:
hackrush 2019-02-25 12:39:44 +05:30
parent 0b032c5346
commit e6240b14ee
2 changed files with 8 additions and 4 deletions

View file

@ -25,7 +25,8 @@ def display(data):
async def execute_command(conf, method, params):
async with aiohttp.ClientSession() as session:
conn = aiohttp.NamedPipeConnector(path=r'\\.\pipe\lbrypipe')
async with aiohttp.ClientSession(connector=conn) as session:
try:
message = {'method': method, 'params': params}
async with session.get(conf.api_connection_url, json=message) as resp:

View file

@ -286,6 +286,7 @@ class Daemon(metaclass=JSONRPCServerType):
logging.getLogger('aiohttp.access').setLevel(logging.WARN)
app = web.Application()
app.router.add_get('/lbryapi', self.handle_old_jsonrpc)
app.router.add_get('/', self.handle_old_jsonrpc)
app.router.add_post('/lbryapi', self.handle_old_jsonrpc)
app.router.add_post('/', self.handle_old_jsonrpc)
self.runner = web.AppRunner(app)
@ -414,9 +415,11 @@ class Daemon(metaclass=JSONRPCServerType):
await self.runner.setup()
try:
loop = asyncio.get_event_loop()
await loop.start_serving_pipe(lambda : NamedPipeServer(self.handle_pipe_request), PIPE_NAME)
log.info('lbrynet API listening on pipe %s', PIPE_NAME)
site = web.NamedPipeSite(self.runner, PIPE_NAME)
await site.start()
# loop = asyncio.get_event_loop()
# await loop.start_serving_pipe(lambda : NamedPipeServer(self.handle_pipe_request), PIPE_NAME)
log.info('lbrynet API listening on pipe %s', site.name)
except Exception as e:
log.error(str(e))