Spaces:
Running
on
Zero
Running
on
Zero
Refactor active process management in app.py
Browse filesConsolidate global variable declarations for active process management within the run_training and _stop_active_training functions. This change improves code clarity and ensures consistent handling of active training processes, enhancing overall functionality.
app.py
CHANGED
|
@@ -662,6 +662,7 @@ def run_training(
|
|
| 662 |
max_epochs: int,
|
| 663 |
save_every: int,
|
| 664 |
) -> Iterable[tuple]:
|
|
|
|
| 665 |
# Basic validation
|
| 666 |
log_buf = ""
|
| 667 |
ckpts: List[str] = []
|
|
@@ -851,7 +852,6 @@ def _stop_active_training() -> None:
|
|
| 851 |
)
|
| 852 |
# Register active process for hard stop
|
| 853 |
with _ACTIVE_LOCK:
|
| 854 |
-
global _ACTIVE_PROC, _ACTIVE_PGID
|
| 855 |
_ACTIVE_PROC = proc
|
| 856 |
try:
|
| 857 |
_ACTIVE_PGID = os.getpgid(proc.pid)
|
|
|
|
| 662 |
max_epochs: int,
|
| 663 |
save_every: int,
|
| 664 |
) -> Iterable[tuple]:
|
| 665 |
+
global _ACTIVE_PROC, _ACTIVE_PGID
|
| 666 |
# Basic validation
|
| 667 |
log_buf = ""
|
| 668 |
ckpts: List[str] = []
|
|
|
|
| 852 |
)
|
| 853 |
# Register active process for hard stop
|
| 854 |
with _ACTIVE_LOCK:
|
|
|
|
| 855 |
_ACTIVE_PROC = proc
|
| 856 |
try:
|
| 857 |
_ACTIVE_PGID = os.getpgid(proc.pid)
|