向Session注册一个回调函数,返回回调id :param Callable callback: 回调函数. 函数签名为 ``callback(data)``. ``data`` 参数为回调事件的值 :param bool serial_mode: 串行模式模式。若为 ``True`` ,则对于同一组件的点击事件,串行执行其回调函数
(self, callback, serial_mode=False)
| 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 交互函数。 |
nothing calls this directly
no test coverage detected