MCPcopy Index your code
hub / github.com/pywebio/PyWebIO / register_callback

Method register_callback

pywebio/session/threadbased.py:277–290  ·  view source on GitHub ↗

向Session注册一个回调函数,返回回调id :param Callable callback: 回调函数. 函数签名为 ``callback(data)``. ``data`` 参数为回调事件的值 :param bool serial_mode: 串行模式模式。若为 ``True`` ,则对于同一组件的点击事件,串行执行其回调函数

(self, callback, serial_mode=False)

Source from the content-addressed store, hash-verified

275 t.start()
276
277 def register_callback(self, callback, serial_mode=False):
278 """ 向Session注册一个回调函数,返回回调id
279
280 :param Callable callback: 回调函数. 函数签名为 ``callback(data)``. ``data`` 参数为回调事件的值
281 :param bool serial_mode: 串行模式模式。若为 ``True`` ,则对于同一组件的点击事件,串行执行其回调函数
282 """
283 assert (not iscoroutinefunction(callback)) and (not isgeneratorfunction(callback)), ValueError(
284 "In ThreadBasedSession.register_callback, `callback` must be a simple function, "
285 "not coroutine function or generator function. ")
286
287 self._activate_callback_env()
288 callback_id = 'CB-%s-%s' % (get_function_name(callback, 'callback'), random_str(10))
289 self.callbacks[callback_id] = (callback, serial_mode)
290 return callback_id
291
292 def register_thread(self, t: threading.Thread):
293 """将线程注册到当前会话,以便在线程内调用 pywebio 交互函数。

Callers

nothing calls this directly

Calls 5

iscoroutinefunctionFunction · 0.85
isgeneratorfunctionFunction · 0.85
get_function_nameFunction · 0.85
random_strFunction · 0.85

Tested by

no test coverage detected