fix: don't use static properties

This commit is contained in:
sati.ac 2023-09-08 15:16:12 +03:00
parent 4ec4bb9aac
commit bfa6d717c2
3 changed files with 4 additions and 20 deletions

@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project] [project]
name = "sati-ac" name = "sati-ac"
version = "0.1.1" version = "0.1.2"
authors = [ authors = [
{ name="sati.ac", email="sati.ac@proton.me" } { name="sati.ac", email="sati.ac@proton.me" }
] ]

@ -5,7 +5,6 @@ from .util import SatiDict
from .socket import SatiSocket from .socket import SatiSocket
class UnableToSolveTask(Exception): class UnableToSolveTask(Exception):
task: SatiDict
def __init__(self, task: SatiDict): def __init__(self, task: SatiDict):
super().__init__(f"sati: unable to solve {task.type} task #{task.id}") super().__init__(f"sati: unable to solve {task.type} task #{task.id}")
self.task = task self.task = task
@ -23,10 +22,6 @@ class Sati:
>>> print(task.result.token) >>> print(task.result.token)
''' '''
_socket: SatiSocket
_project_id: int
_awaited_tasks: dict
def __init__( def __init__(
self, self,
token: str, token: str,

@ -16,8 +16,6 @@ class SatiUnrecoverableException(Exception):
class SatiException(Exception): class SatiException(Exception):
''' api error ''' ''' api error '''
code: int
def __init__(self, message: str, code: int = 0): def __init__(self, message: str, code: int = 0):
super().__init__(f"sati: #{code}: {message}") super().__init__(f"sati: #{code}: {message}")
self.code = code self.code = code
@ -30,18 +28,6 @@ class QueueEntry:
class SatiSocket: class SatiSocket:
''' low-level api wrapper ''' ''' low-level api wrapper '''
__token: str
__state: int = STATE_RECONNECTING
__socket: typing.Any
__reconnection_interval: float
__connector_ref: asyncio.Task
__id_counter: int = 0
__awaited_replies: dict
__error = None
__queue: list
__url: str
__event_handlers: dict
__debug: bool
def __init__( def __init__(
self, self,
@ -58,6 +44,9 @@ class SatiSocket:
self.__url = url self.__url = url
self.__connector_ref = asyncio.create_task(self.__connector()) self.__connector_ref = asyncio.create_task(self.__connector())
self.__debug = debug self.__debug = debug
self.__error = None
self.__id_counter = 0
self.__state = STATE_RECONNECTING
async def __connector(self): async def __connector(self):
while self.__state != STATE_UNRECOVERABLE: while self.__state != STATE_UNRECOVERABLE: