@@ -7,11 +7,11 @@ include "cefpython.pyx"
77g_taskMaxId = 0
88g_tasks = {}
99
10- def PostTask (int threadId , object func , *args ):
10+ def PostTask (int thread , object func , *args ):
1111 global g_tasks, g_taskMaxId
1212
1313 # Validate threadId.
14- if threadId not in g_browserProcessThreads:
14+ if thread not in g_browserProcessThreads:
1515 raise Exception (" PoastTask failed: requires a browser process thread" )
1616
1717 # Validate func.
@@ -31,7 +31,35 @@ def PostTask(int threadId, object func, *args):
3131 # Call C++ wrapper.
3232 cdef int cTaskId = int (g_taskMaxId)
3333 with nogil:
34- PostTaskWrapper(threadId, cTaskId)
34+ PostTaskWrapper(thread, cTaskId)
35+
36+
37+ def PostDelayedTask (int thread , int delay_ms , object func , *args ):
38+ global g_tasks, g_taskMaxId
39+
40+ # Validate threadId.
41+ if thread not in g_browserProcessThreads:
42+ raise Exception (" PoastTask failed: requires a browser process thread" )
43+
44+ # Validate func.
45+ if not IsFunctionOrMethod(type (func)):
46+ raise Exception (" PostTask failed: not a function nor method" )
47+
48+ # Params.
49+ cdef list params = list (args)
50+
51+ # Keep func and params until PyTaskRunnable is called.
52+ g_taskMaxId += 1
53+ g_tasks[str (g_taskMaxId)] = {
54+ " func" : func,
55+ " params" : params
56+ }
57+
58+ # Call C++ wrapper.
59+ cdef int cTaskId = int (g_taskMaxId)
60+ with nogil:
61+ PostDelayedTaskWrapper(thread, delay_ms, cTaskId)
62+
3563
3664cdef public void PyTaskRunnable(int taskId) except * with gil:
3765 cdef object func
0 commit comments