MCPcopy Index your code
hub / github.com/dagger/dagger / main

Function main

sdk/python/src/dagger/mod/cli.py:33–51  ·  view source on GitHub ↗

Async entrypoint for a Dagger module.

(mod: Module | None = None, register: bool = False)

Source from the content-addressed store, hash-verified

31
32
33async def main(mod: Module | None = None, register: bool = False) -> int | None:
34 """Async entrypoint for a Dagger module."""
35 # Establishing connection early on to allow returning dag.error().
36 # Note: if there's a connection error dag.error() won't be sent but
37 # should be logged and the traceback shown on the function's stderr output.
38 async with await dagger.connect():
39 try:
40 if mod is None:
41 mod = load_module()
42 if register:
43 return await mod.register()
44 return await mod.serve()
45 except (ModuleError, dagger.QueryError) as e:
46 await record_exception(e)
47 return 2
48 except Exception as e:
49 logger.exception("Unhandled exception")
50 await record_exception(e)
51 return 1
52
53
54def load_module() -> Module:

Callers

nothing calls this directly

Calls 5

record_exceptionFunction · 0.90
load_moduleFunction · 0.85
connectMethod · 0.45
registerMethod · 0.45
serveMethod · 0.45

Tested by

no test coverage detected