AsyncManager#

class braintools.file.AsyncManager(max_workers=1)[source]#

A simple object to track async checkpointing.

This class is rewritten from the Flax APIs (google/flax).

Can be used as a context manager for automatic resource cleanup:

Example

with AsyncManager() as manager:

msgpack_save(filename, target, async_manager=manager)

close()[source]#

Explicitly close the AsyncManager and release resources.

Waits for any pending save to complete, then shuts down the executor.

save_async(task)[source]#

Run a task async. The future will be tracked as self.save_future.

Parameters:

task (Callable[[], Any]) – The callable to be executed asynchronously.

Raises:

RuntimeError – If the AsyncManager has been closed.

wait_previous_save()[source]#

Block until the previous save finishes, to keep files’ consistency.