@@ -123,8 +123,8 @@ async def start(self):
123123 try :
124124 await self .connection .connect ()
125125
126- self .net_worker_task = asyncio .create_task (self .net_worker ())
127- self .recv_task = asyncio .create_task (self .recv ())
126+ self .net_worker_task = asyncio .ensure_future (self .net_worker ())
127+ self .recv_task = asyncio .ensure_future (self .recv ())
128128
129129 self .current_salt = FutureSalt (0 , 0 , Session .INITIAL_SALT )
130130 self .current_salt = FutureSalt (
@@ -137,7 +137,7 @@ async def start(self):
137137 self .current_salt = \
138138 (await self ._send (functions .GetFutureSalts (num = 1 ), timeout = self .START_TIMEOUT )).salts [0 ]
139139
140- self .next_salt_task = asyncio .create_task (self .next_salt ())
140+ self .next_salt_task = asyncio .ensure_future (self .next_salt ())
141141
142142 if not self .is_cdn :
143143 await self ._send (
@@ -157,7 +157,7 @@ async def start(self):
157157 timeout = self .START_TIMEOUT
158158 )
159159
160- self .ping_task = asyncio .create_task (self .ping ())
160+ self .ping_task = asyncio .ensure_future (self .ping ())
161161
162162 log .info ("Session initialized: Layer {}" .format (layer ))
163163 log .info ("Device: {} - {}" .format (self .client .device_model , self .client .app_version ))
@@ -351,7 +351,7 @@ async def recv(self):
351351 log .warning ("Server sent \" {}\" " .format (Int .read (BytesIO (packet ))))
352352
353353 if self .is_connected .is_set ():
354- asyncio .create_task (self .restart ())
354+ asyncio .ensure_future (self .restart ())
355355
356356 break
357357
0 commit comments