Determine the compile trigger and claim the dev backend reload marker. Atomically creates the marker so a failed first compile is still treated as the first worker boot: the next worker (after the user fixes the error) will see the marker and report ``hot_reload``. If the marker can
()
| 49 | |
| 50 | |
| 51 | def get_backend_compile_trigger() -> CompileTrigger: |
| 52 | """Determine the compile trigger and claim the dev backend reload marker. |
| 53 | |
| 54 | Atomically creates the marker so a failed first compile is still treated |
| 55 | as the first worker boot: the next worker (after the user fixes the |
| 56 | error) will see the marker and report ``hot_reload``. If the marker |
| 57 | cannot be created (e.g. permission error, missing parent dir), falls |
| 58 | back to ``backend_startup``. |
| 59 | |
| 60 | Returns: |
| 61 | ``"backend_startup"`` for non-dev startups and the first dev |
| 62 | reload-capable worker boot, ``"hot_reload"`` for subsequent boots. |
| 63 | """ |
| 64 | if not environment.REFLEX_DEV_BACKEND_RELOAD_ACTIVE.get(): |
| 65 | return "backend_startup" |
| 66 | try: |
| 67 | os.close(os.open(get_dev_backend_reload_marker(), os.O_CREAT | os.O_EXCL)) |
| 68 | except FileExistsError: |
| 69 | return "hot_reload" |
| 70 | except OSError: |
| 71 | pass |
| 72 | return "backend_startup" |
| 73 | |
| 74 | |
| 75 | def get_package_json_and_hash(package_json_path: Path) -> tuple[PackageJson, str]: |
no test coverage detected