Cache API
This commit is contained in:
5
rpc.py
5
rpc.py
@@ -5,12 +5,15 @@ import socket
|
||||
import threading
|
||||
import asyncio
|
||||
import warnings
|
||||
import logging
|
||||
from collections import namedtuple
|
||||
|
||||
from XWBHash import encrypt0 as XWBHash_encrypt
|
||||
|
||||
from typing import Any, Union, Sequence
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class RPCExc(Exception): pass
|
||||
class RPCExcFormat(ValueError, RPCExc): pass
|
||||
class RPCExcAuth(RPCExc): pass
|
||||
@@ -121,6 +124,7 @@ class ClientSync(object):
|
||||
if (res := rpc_unpack_result(next(self.recv_rpc_msg), encoding=encoding)) != '1':
|
||||
raise RPCExcInvalidResult('XWB CREATE CONTEXT', context[0], res)
|
||||
self.context = context[0]
|
||||
logger.warning(f'RPC: {name} [{self.context}] {args}' if context else f'{name} {args}')
|
||||
send_rpc_msg(self.sock, rpc_pack(name, *args, command=command, envelope=envelope, encoding=encoding))
|
||||
return rpc_unpack_result(next(self.recv_rpc_msg), encoding=encoding)
|
||||
def __getattr__(self, key: str, commands: set={'TCPConnect'}):
|
||||
@@ -196,6 +200,7 @@ class ClientAsync(object):
|
||||
if (res := rpc_unpack_result(await self.arecv_rpc_msg.__anext__(), encoding=encoding)) != '1':
|
||||
raise RPCExcInvalidResult('XWB CREATE CONTEXT', context[0], res)
|
||||
self.context = context[0]
|
||||
logger.warning(f'RPC: {name} [{self.context}] {args}' if context else f'{name} {args}')
|
||||
await asend_rpc_msg(self.writer, rpc_pack(name, *args, command=command, envelope=envelope, encoding=encoding))
|
||||
return rpc_unpack_result(await self.arecv_rpc_msg.__anext__(), encoding=encoding)
|
||||
def __getattr__(self, key: str, commands: set={'TCPConnect'}):
|
||||
|
Reference in New Issue
Block a user