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

Method main_task

pywebio/session/threadbased.py:84–108  ·  view source on GitHub ↗
(target)

Source from the content-addressed store, hash-verified

82
83 @wraps(target)
84 def main_task(target):
85 try:
86 target()
87 except Exception as e:
88 if not isinstance(e, SessionException):
89 self.on_task_exception()
90 finally:
91 for t in self.threads:
92 if t.is_alive() and t is not threading.current_thread():
93 t.join()
94
95 try:
96 if self.need_keep_alive():
97 from ..session import hold
98 hold()
99 else:
100 self.send_task_command(dict(command='close_session'))
101 except SessionException: # ignore SessionException error
102 pass
103 finally:
104 # we need first trigger close event and then perform close operation,
105 # because close operation will clean up all resources in this session,
106 # which may need to be accessed in close event
107 self._trigger_close_event()
108 self.close()
109
110 thread = threading.Thread(target=main_task, kwargs=dict(target=target),
111 daemon=True, name='main_task')

Callers

nothing calls this directly

Calls 7

need_keep_aliveMethod · 0.95
send_task_commandMethod · 0.95
_trigger_close_eventMethod · 0.95
closeMethod · 0.95
holdFunction · 0.85
on_task_exceptionMethod · 0.80
targetFunction · 0.50

Tested by

no test coverage detected