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

Method session_context

pywebio/session/coroutinebased.py:271–284  ·  view source on GitHub ↗

>>> with session_context(): ... res = self.coros[-1].send(data)

(self)

Source from the content-addressed store, hash-verified

269
270 @contextmanager
271 def session_context(self):
272 """
273 >>> with session_context():
274 ... res = self.coros[-1].send(data)
275 """
276
277 # todo issue: with 语句可能发生嵌套,导致内层with退出时,将属性置空
278 _context.current_session = self.session
279 _context.current_task_id = self.coro_id
280 try:
281 yield
282 finally:
283 _context.current_session = None
284 _context.current_task_id = None
285
286 @staticmethod
287 def gen_coro_id(coro=None):

Callers 1

stepMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected