File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed
Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ local event_sub = {}
44genv .temp = temp
55local url = ' http://127.0.0.1:4343/'
66local tasks = {}
7+ local ycounts = {}
78
89ws = http .websocket (url .. ' ws/' )
910if ws == false then
@@ -39,6 +40,7 @@ while true do
3940 action = ' task_result' ,
4041 task_id = msg .task_id ,
4142 result = {false , err },
43+ yields = 0 ,
4244 })
4345 else
4446 setfenv (fn , genv )
@@ -47,9 +49,11 @@ while true do
4749 action = ' task_result' ,
4850 task_id = msg .task_id ,
4951 result = {fn ()},
52+ yields = 0 ,
5053 })
5154 else
5255 tasks [msg .task_id ] = coroutine.create (fn )
56+ ycounts [msg .task_id ] = 0
5357 end
5458 end
5559 elseif msg .action == ' sub' then
@@ -80,12 +84,16 @@ while true do
8084 action = ' task_result' ,
8185 task_id = task_id ,
8286 result = r ,
87+ yields = ycounts [task_id ],
8388 })
8489 del_tasks [task_id ] = true
90+ else
91+ ycounts [msg .task_id ] = ycounts [msg .task_id ] + 1
8592 end
8693 end
8794 for task_id in pairs (del_tasks ) do
8895 tasks [task_id ] = nil
96+ ycounts [msg .task_id ] = nil
8997 end
9098end
9199
Original file line number Diff line number Diff line change @@ -223,6 +223,7 @@ async def ws(self, request):
223223 elif msg ['action' ] == 'task_result' :
224224 api ._result_values [msg ['task_id' ]] = msg ['result' ]
225225 api ._result_locks [msg ['task_id' ]].set ()
226+ # print(msg['task_id'], msg['yields'])
226227 else :
227228 await ws .send_json ({
228229 'action' : 'close' ,
You can’t perform that action at this time.
0 commit comments