MCPcopy Create free account
hub / github.com/apple/axlearn / teardown

Method teardown

axlearn/common/array_serialization.py:108–123  ·  view source on GitHub ↗

Release TensorStore context and event loop on colocated Python workers.

(self)

Source from the content-addressed store, hash-verified

106 ).result()
107
108 def teardown(self):
109 """Release TensorStore context and event loop on colocated Python workers."""
110 if hasattr(self, "event_loop") and self.event_loop is not None:
111 # Shut down the default executor before stopping the loop (1 min timeout).
112 asyncio.run_coroutine_threadsafe(
113 self.event_loop.shutdown_default_executor(
114 timeout=60
115 ), # pytype: disable=wrong-keyword-args
116 self.event_loop,
117 ).result()
118 self.event_loop.call_soon_threadsafe(self.event_loop.stop)
119 self.loop_thread.join()
120 self.event_loop.close()
121 self.event_loop = None
122 self.ts_context = None
123 logging.info("ColocatedStateManager destroyed on sidecar.")
124
125 def __del__(self):
126 self.teardown()

Callers 1

__del__Method · 0.95

Calls 3

joinMethod · 0.80
resultMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected