---
title: utils | CodeWeaver Docs
description: API reference for codeweaver.core.dependencies.utils
url: "https://docs.knitli.com/api/core/dependencies/utils"
type: static
generatedAt: "2026-04-17T17:21:07.970Z"
---

# utils
       [Open in ChatGPT](https://chatgpt.com/?q=Read%20https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fcore%2Fdependencies%2Futils%2F.%20I%20want%20to%20ask%20questions%20about%20it.)[Open in Claude](https://claude.ai/new?q=Read%20https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fcore%2Fdependencies%2Futils%2F.%20I%20want%20to%20ask%20questions%20about%20it.)[View in Markdown](/codeweaver/api/core/dependencies/utils.md)       [Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fcore%2Fdependencies%2Futils%2F)[Share on X](https://x.com/intent/tweet?url=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fcore%2Fdependencies%2Futils%2F&text=utils)[Share on Threads](https://threads.net/intent/post?url=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fcore%2Fdependencies%2Futils%2F&text=utils)[Share on Bluesky](https://bsky.app/intent/compose?text=utils%20https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fcore%2Fdependencies%2Futils%2F)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fcore%2Fdependencies%2Futils%2F)[Share on Reddit](https://reddit.com/submit?url=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fcore%2Fdependencies%2Futils%2F&title=utils)[Share on Hacker News](https://news.ycombinator.com/submitlink?u=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fcore%2Fdependencies%2Futils%2F&t=utils)[Share on Email](mailto:?subject=utils&body=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fcore%2Fdependencies%2Futils%2F)[Share on WhatsApp](https://wa.me/?text=utils%20https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fcore%2Fdependencies%2Futils%2F)[Share on Telegram](https://t.me/share/url?url=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fcore%2Fdependencies%2Futils%2F&text=utils)
# `codeweaver.core.dependencies.utils`
[Section titled “codeweaver.core.dependencies.utils”](#codeweavercoredependenciesutils)
Utilities for setting up dependencies.

## Function: `ensure_container_initialized`
[Section titled “Function: ensure_container_initialized”](#function-ensure_container_initialized)

**

```
ensure_container_initialized()
```

Ensure the DI container is initialized.

This is necessary before importing any modules that might use dependency injection, to avoid circular import issues. It can be called at the top of any module that needs to use dependencies.

## Function: `ensure_settings_initialized`
[Section titled “Function: ensure_settings_initialized”](#function-ensure_settings_initialized)

**

```
ensure_settings_initialized()
```

Ensure settings are initialized in the DI container (sync version).

This checks if settings exist in the container but does NOT attempt async bootstrap. Safe to call at module import time — returns silently if settings are not yet available.

Settings will be bootstrapped later via the async startup path. Use this in sync contexts where the goal is to initialize the container and mark settings ready if they already exist.

Note: For async contexts or initial bootstrap, use ensure_settings_initialized_async() instead, which properly awaits the bootstrap process.

## Function: `ensure_settings_initialized_async`
[Section titled “Function: ensure_settings_initialized_async”](#function-ensure_settings_initialized_async)

**

```
ensure_settings_initialized_async()
```

Ensure settings are initialized in the DI container (async version).

This should be called from async contexts to properly bootstrap settings. It will await the async bootstrap_settings() if needed.

This is the preferred way to initialize settings during application startup, as it properly handles the async nature of the bootstrap process.

Raises: Exception: If settings initialization fails