MCPcopy Index your code
hub / github.com/RustPython/RustPython / callback

Method callback

Lib/asyncio/__main__.py:34–65  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

32 future = concurrent.futures.Future()
33
34 def callback():
35 global return_code
36 global repl_future
37 global keyboard_interrupted
38
39 repl_future = None
40 keyboard_interrupted = False
41
42 func = types.FunctionType(code, self.locals)
43 try:
44 coro = func()
45 except SystemExit as se:
46 return_code = se.code
47 self.loop.stop()
48 return
49 except KeyboardInterrupt as ex:
50 keyboard_interrupted = True
51 future.set_exception(ex)
52 return
53 except BaseException as ex:
54 future.set_exception(ex)
55 return
56
57 if not inspect.iscoroutine(coro):
58 future.set_result(coro)
59 return
60
61 try:
62 repl_future = self.loop.create_task(coro, context=self.context)
63 futures._chain_future(repl_future, future)
64 except BaseException as exc:
65 future.set_exception(exc)
66
67 self.loop.call_soon_threadsafe(callback, context=self.context)
68

Callers

nothing calls this directly

Calls 5

funcFunction · 0.50
stopMethod · 0.45
set_exceptionMethod · 0.45
set_resultMethod · 0.45
create_taskMethod · 0.45

Tested by

no test coverage detected