Stop using loop's time() function

This commit is contained in:
Lonami Exo 2018-06-28 15:12:18 +02:00
parent 491302bb32
commit ac2b10f2a5

View File

@ -1,7 +1,7 @@
import asyncio import asyncio
import itertools import itertools
import logging import logging
import warnings import time
from collections import UserList from collections import UserList
from async_generator import async_generator, yield_ from async_generator import async_generator, yield_
@ -188,7 +188,7 @@ class MessageMethods(UploadMethods, MessageParseMethods):
last_id = float('inf') last_id = float('inf')
batch_size = min(max(batch_size, 1), 100) batch_size = min(max(batch_size, 1), 100)
while have < limit: while have < limit:
start = asyncio.get_event_loop().time() start = time.time()
# Telegram has a hard limit of 100 # Telegram has a hard limit of 100
request.limit = min(limit - have, batch_size) request.limit = min(limit - have, batch_size)
r = await self(request) r = await self(request)
@ -242,9 +242,8 @@ class MessageMethods(UploadMethods, MessageParseMethods):
else: else:
request.max_date = last_message.date request.max_date = last_message.date
now = asyncio.get_event_loop().time()
await asyncio.sleep( await asyncio.sleep(
max(wait_time - (now - start), 0), loop=self._loop) max(wait_time - (time.time() - start), 0), loop=self._loop)
async def get_messages(self, *args, **kwargs): async def get_messages(self, *args, **kwargs):
""" """