根据target_func函数类型注册会话实现,并返回会话实现 Register the session implementation according to the target_func function type, and return the session implementation
(target_func)
| 188 | |
| 189 | |
| 190 | def register_session_implement_for_target(target_func): |
| 191 | """根据target_func函数类型注册会话实现,并返回会话实现 |
| 192 | Register the session implementation according to the target_func function type, and return the session implementation""" |
| 193 | if iscoroutinefunction(target_func) or isgeneratorfunction(target_func): |
| 194 | cls = CoroutineBasedSession |
| 195 | else: |
| 196 | cls = ThreadBasedSession |
| 197 | |
| 198 | if ScriptModeSession in _active_session_cls: |
| 199 | raise RuntimeError("Already in script mode, can't start server") |
| 200 | |
| 201 | if cls not in _active_session_cls: |
| 202 | _active_session_cls.append(cls) |
| 203 | |
| 204 | return cls |
| 205 | |
| 206 | |
| 207 | def get_session_implement(): |
no test coverage detected
searching dependent graphs…