Skip to content

docs: describe agent.safe_open() usage - #1367

Merged
DavidePrincipi merged 1 commit into
mainfrom
docs-safe-open
Oct 16, 2026
Merged

DavidePrincipi merged 1 commit into
mainfrom
docs-safe-open

Conversation

@DavidePrincipi

Copy link
Copy Markdown
Member

The Python agent library offers agent.safe_open() to write files atomically, but the developer manual never mentions it. This PR documents it so that module developers can use it instead of writing their own temporary-file-and-rename logic.

There is no behavior change: this is a documentation-only update to the "Code snippets" page of the Modules section.

  • New "Atomic file write" section in docs/modules/code_snippets.md, with an example, the supported file modes, how file permissions are handled, and what happens on errors.
  • It lists the current users of the function: agent.set_env() / agent.write_envfile() and the rclonegwctl HAProxy configuration.
  • It also documents agent.exclusive_file_lock(), because safe_open() alone does not protect a read-modify-write cycle from concurrent writers.

Generated by Claude Code:claude-haiku-5-5 with nethserver-pr

The safe_open() and exclusive_file_lock() helpers of the Python agent
library were not documented. Module developers can use them to write
files atomically and to serialize read-modify-write cycles, as the
agent library already does for the environment file.

Assisted-by: Claude Code:claude-haiku-5-5
@DavidePrincipi
DavidePrincipi merged commit 713925d into main Oct 16, 2026
@DavidePrincipi
DavidePrincipi deleted the docs-safe-open branch October 16, 2026 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants