MCPcopy Create free account
hub / github.com/dagger/dagger / __exit__

Method __exit__

sdk/python/src/dagger/provisioning/_session.py:50–65  ·  view source on GitHub ↗
(self, exc_type, exc_value, traceback)

Source from the content-addressed store, hash-verified

48 timeout: int = 300
49
50 def __exit__(self, exc_type, exc_value, traceback):
51 # Kill the child process by closing stdin, not via SIGKILL, so it has
52 # a chance to drain logs.
53 try:
54 if self.proc.stdin:
55 self.proc.stdin.close()
56 except AttributeError:
57 # FakeProcess doesn't have a stdin attribute (tests)
58 self.proc.terminate()
59
60 try:
61 self._wait()
62 except Exception: # Including KeyboardInterrupt, wait handled that.
63 self.proc.kill()
64 # We don't call proc.wait() again as proc.__exit__ does that for us.
65 raise
66
67 def _wait(self):
68 # avoids raise-within-try (TRY301)

Callers 1

__exit__Method · 0.45

Calls 2

_waitMethod · 0.95
closeMethod · 0.45

Tested by

no test coverage detected