kopia lustrzana https://github.com/cirospaciari/socketify.py
relax performance cpu test
rodzic
8e82f8d061
commit
76e96f978e
|
@ -1 +1 @@
|
|||
git+https://github.com/cirospaciari/socketify.py.git@main#socketify --global-option="build_ext"
|
||||
git+https://github.com/cirospaciari/socketify.py.git@main#socketify
|
|
@ -1 +1 @@
|
|||
git+https://github.com/cirospaciari/socketify.py.git@main#socketify --global-option="build_ext"
|
||||
git+https://github.com/cirospaciari/socketify.py.git@main#socketify
|
|
@ -1 +1 @@
|
|||
git+https://github.com/cirospaciari/socketify.py.git@main#socketify --global-option="build_ext"
|
||||
git+https://github.com/cirospaciari/socketify.py.git@main#socketify
|
|
@ -39,6 +39,7 @@ 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)
|
||||
|
@ -58,8 +59,11 @@ class Loop:
|
|||
(callback, user_data) = loop.queue.get(False)
|
||||
callback(user_data)
|
||||
loop.queue.task_done()
|
||||
#run once asyncio
|
||||
loop.run_once_asyncio()
|
||||
#run once asyncio if has some current task running or relax CPU
|
||||
if not asyncio.current_task(loop.loop) is None or self.last_run >= 100:
|
||||
loop.run_once_asyncio()
|
||||
self.last_run = 0
|
||||
self.last_run = self.last_run + 1
|
||||
#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_check(tick, self)
|
||||
|
|
|
@ -595,8 +595,6 @@ class AppResponse:
|
|||
return None #invalid json
|
||||
|
||||
|
||||
|
||||
|
||||
def send_chunk(self, buffer, total_size):
|
||||
self._chunkFuture = self.loop.create_future()
|
||||
self._lastChunkOffset = 0
|
||||
|
@ -604,7 +602,6 @@ class AppResponse:
|
|||
def is_aborted(self):
|
||||
self.aborted = True
|
||||
try:
|
||||
print("aborted!", self._chunkFuture.done())
|
||||
if not self._chunkFuture.done():
|
||||
self._chunkFuture.set_result((False, True)) #if aborted set to done True and ok False
|
||||
except:
|
||||
|
|
Ładowanie…
Reference in New Issue