3
3
import asyncio
4
4
import logging
5
5
from abc import ABC
6
- from asyncio import Lock , TimerHandle , Transport
6
+ from asyncio import Lock , TimerHandle , Transport , get_running_loop
7
7
from collections .abc import Callable
8
8
from dataclasses import dataclass
9
9
@@ -72,7 +72,8 @@ async def keep_alive_func(self, _=None):
72
72
await self .ping ()
73
73
except RoborockException :
74
74
pass
75
- self .keep_alive_task = self .event_loop .call_later (10 , lambda : asyncio .create_task (self .keep_alive_func ()))
75
+ loop = asyncio .get_running_loop ()
76
+ self .keep_alive_task = loop .call_later (10 , lambda : asyncio .create_task (self .keep_alive_func ()))
76
77
77
78
async def async_connect (self ) -> None :
78
79
should_ping = False
@@ -82,7 +83,8 @@ async def async_connect(self) -> None:
82
83
self ._sync_disconnect ()
83
84
async with async_timeout .timeout (self .queue_timeout ):
84
85
self ._logger .debug (f"Connecting to { self .host } " )
85
- self .transport , _ = await self .event_loop .create_connection ( # type: ignore
86
+ loop = get_running_loop ()
87
+ self .transport , _ = await loop .create_connection ( # type: ignore
86
88
lambda : self ._local_protocol , self .host , 58867
87
89
)
88
90
self ._logger .info (f"Connected to { self .host } " )
@@ -94,7 +96,8 @@ async def async_connect(self) -> None:
94
96
await self .keep_alive_func ()
95
97
96
98
def _sync_disconnect (self ) -> None :
97
- if self .transport and self .event_loop .is_running ():
99
+ loop = asyncio .get_running_loop ()
100
+ if self .transport and loop .is_running ():
98
101
self ._logger .debug (f"Disconnecting from { self .host } " )
99
102
self .transport .close ()
100
103
if self .keep_alive_task :
0 commit comments