kopia lustrzana https://github.com/cirospaciari/socketify.py
relaxed timer perf test
rodzic
ab81096f6f
commit
7ee96a8a1b
|
@ -39,7 +39,6 @@ class Loop:
|
|||
asyncio.set_event_loop(self.loop)
|
||||
self.started = False
|
||||
self.last_defer = False
|
||||
self.last_run = 0
|
||||
|
||||
def set_timeout(self, timeout, callback, user_data):
|
||||
return self.uv_loop.create_timer(timeout, 0, callback, user_data)
|
||||
|
@ -59,13 +58,11 @@ class Loop:
|
|||
(callback, user_data) = loop.queue.get(False)
|
||||
callback(user_data)
|
||||
loop.queue.task_done()
|
||||
#run once asyncio if has some current task running or relax CPU
|
||||
if not asyncio.current_task(loop.loop) is None or loop.last_run >= 10:
|
||||
loop.run_once_asyncio()
|
||||
loop.last_run = 0
|
||||
loop.last_run = loop.last_run + 1
|
||||
#run once asyncio
|
||||
loop.run_once_asyncio()
|
||||
|
||||
#use check for calling asyncio once per tick
|
||||
self.timer = self.uv_loop.create_timer(0, 1, tick, self)
|
||||
self.timer = self.uv_loop.create_timer(0, 10, tick, self)
|
||||
# self.timer = self.uv_loop.create_check(tick, self)
|
||||
|
||||
def run(self):
|
||||
|
|
Ładowanie…
Reference in New Issue