fix: run the make instances driver on system python3 3.9

datetime.UTC exists only since Python 3.11, so make instances failed on
the macOS system python3 listed in the report prerequisites. Use
timezone.utc and postponed annotations instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-11 22:20:22 +03:00
co-authored by Claude Opus 5.5
parent 063eedbc71
commit b0637addea
3 changed files with 13 additions and 669 deletions
+3 -1
View File
@@ -16,7 +16,9 @@ HAProxy на `APP_OUT_PORT` перед репликами API) работают
сессии по репликам, `kill-inflight` — kill реплики с запросами в
полёте, `idle-conns` — кто закрывает простаивающие соединения LB →
реплика и `hang-key` — повтор ключа после зависшей реплики. Только
стандартная библиотека Python.
стандартная библиотека Python 3.9+: `make instances` запускает драйвер
системным `python3` (на macOS — 3.9), поэтому без `datetime.UTC`,
`match` и прочего синтаксиса 3.10+.
Все пути — от корня репозитория. Проверено на macOS (arm64), uv 0.12,
Python 3.12 из `.python-version`, Docker Desktop 29.8.
+10 -1
View File
@@ -43,6 +43,11 @@
stop остановить свой экземпляр на порту
all start → flow → smoke → student (если есть student-tests/) → stop
Работает на python3 3.9+ (системный python3 macOS): `make instances`
вызывает его без uv. Отсюда `from __future__ import annotations` и
`timezone.utc` вместо `datetime.UTC` (3.11+, `noqa: UP017`: ruff
проекта целится в py312 и иначе вернул бы `datetime.UTC`).
Порт по умолчанию 18080, а не 8080: на 8080 обычно работает стенд
`make run_docker` (HAProxy перед репликами API) или `make run_dev`
пользователя, и их процессы трогать не надо. Экземпляр драйвера пишет в
@@ -51,6 +56,8 @@
балансировщик (`--port 8080`).
"""
from __future__ import annotations
import argparse
import base64
import contextlib
@@ -68,9 +75,11 @@ import urllib.error
import urllib.request
import uuid
from collections import Counter
from datetime import UTC, datetime
from datetime import datetime, timezone
from pathlib import Path
# datetime.UTC появился в 3.11, а драйвер работает и на python3 3.9
UTC = timezone.utc # noqa: UP017
ROOT = Path(__file__).resolve().parents[3]
DEFAULT_PORT = 18080
USERS = "/api/v1/users"