Skip to content

restart_on: a folder pattern fires when Python creates __pycache__ in it #463

Closed

Description

@7schmiede

What happens

A dev server (kind = "devserver") of a Python service with a folder in restart_on:

restart_on = ["shared", "api"]

restarts once or twice right after devstack up, without any edit. The first start of the Python process creates __pycache__/ folders in the imported packages, and the daemon log reports the parent folders as changed:

{"event":"restart_on","paths":["shared"],"service":"api", ...}
{"event":"restart_on","paths":["api","api/content_extraction"],"service":"api", ...}

The services in the same stack that import those packages all restart once; a job they wait for (after) runs again too.

Expected

The stack file reference says generated directories, __pycache__ among them, "never count as changes". Creating one should not count as a change of the folder that holds it, so a folder pattern in restart_on stays quiet.

Workaround

Name file types instead of the folder: restart_on = ["shared/**/*.py", "api/**/*.py"] (or set PYTHONDONTWRITEBYTECODE=1).

Environment

devstack 0.40.0, Windows 11, Python 3.12 (uv venv), main working tree.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions