@@ -49,7 +49,7 @@ def __init__(self, bot: core.Bot) -> None:
49
49
self .bot = bot
50
50
51
51
self .session : aiohttp .ClientSession | None = None
52
- self .backoff : ExponentialBackoff = ExponentialBackoff () # type: ignore
52
+ self .backoff : ExponentialBackoff [ bool ] = ExponentialBackoff ()
53
53
self .websocket : aiohttp .ClientWebSocketResponse | None = None
54
54
55
55
self .connection_task : asyncio .Task [None ] | None = None
@@ -68,7 +68,7 @@ async def cog_unload(self) -> None:
68
68
try :
69
69
self .connection_task .cancel ()
70
70
except Exception as e :
71
- LOGGER .debug (f'Unable to cancel Pythonista API connection_task in "cog_unload": { e } ' )
71
+ LOGGER .error (f'Unable to cancel Pythonista API connection_task in "cog_unload": { e } ' )
72
72
73
73
if self .is_connected ():
74
74
assert self .websocket
@@ -78,7 +78,7 @@ async def cog_unload(self) -> None:
78
78
try :
79
79
self .keep_alive_task .cancel ()
80
80
except Exception as e :
81
- LOGGER .debug (f'Unable to cancel Pythonista API keep_alive_task in "cog_unload": { e } ' )
81
+ LOGGER .error (f'Unable to cancel Pythonista API keep_alive_task in "cog_unload": { e } ' )
82
82
83
83
def dispatch (self , * , data : dict [str , Any ]) -> None :
84
84
subscription : str = data ["subscription" ]
@@ -98,7 +98,7 @@ async def connect(self) -> None:
98
98
try :
99
99
self .keep_alive_task .cancel ()
100
100
except Exception as e :
101
- LOGGER .debug (f"Failed to cancel Pythonista API Websocket keep alive. This is likely not a problem: { e } " )
101
+ LOGGER .warning (f"Failed to cancel Pythonista API Websocket keep alive. This is likely not a problem: { e } " )
102
102
103
103
while True :
104
104
try :
@@ -108,13 +108,13 @@ async def connect(self) -> None:
108
108
LOGGER .critical ("Unable to connect to Pythonista API Websocket, due to an incorrect token." )
109
109
return
110
110
else :
111
- LOGGER .debug (f"Unable to connect to Pythonista API Websocket: { e } ." )
111
+ LOGGER .error (f"Unable to connect to Pythonista API Websocket: { e } ." )
112
112
113
113
if self .is_connected ():
114
114
break
115
115
else :
116
116
delay : float = self .backoff .delay () # type: ignore
117
- LOGGER .debug (f'Retrying Pythonista API Websocket connection in "{ delay } " seconds.' )
117
+ LOGGER .warning (f'Retrying Pythonista API Websocket connection in "{ delay } " seconds.' )
118
118
119
119
await asyncio .sleep (delay )
120
120
@@ -148,7 +148,7 @@ async def keep_alive(self) -> None:
148
148
op : int | None = data .get ("op" )
149
149
150
150
if op == PAPIWebsocketOPCodes .HELLO :
151
- LOGGER .info (f'Received HELLO from Pythonista API: user={ data ["user_id" ]} ' )
151
+ LOGGER .debug (f'Received HELLO from Pythonista API: user={ data ["user_id" ]} ' )
152
152
153
153
elif op == PAPIWebsocketOPCodes .EVENT :
154
154
self .dispatch (data = data )
0 commit comments