tina4-python 3.13.161__tar.gz → 3.13.163__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {tina4_python-3.13.161 → tina4_python-3.13.163}/PKG-INFO +1 -1
- {tina4_python-3.13.161 → tina4_python-3.13.163}/pyproject.toml +1 -1
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/Testing.py +52 -17
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/__init__.py +1 -1
- tina4_python-3.13.163/tina4_python/_testing_async.py +173 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/ai/__init__.py +2 -2
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/core/middleware.py +19 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/core/server.py +124 -63
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/dev_admin/__init__.py +25 -10
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/mcp/__init__.py +179 -43
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/queue_backends/kafka_backend.py +87 -41
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/test_client/__init__.py +4 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/.gitignore +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/COMMERCIAL-LICENSE.md +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/LICENSE +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/NOTICE +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/README.md +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/.tina4-metrics.json +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/CLAUDE.md +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/HtmlElement.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/_import_helper.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/ai/client.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/api/__init__.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/auth/__init__.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/cache/__init__.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/cli/__init__.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/container/__init__.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/context/__init__.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/context/chunker.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/core/__init__.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/core/cache.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/core/constants.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/core/csp.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/core/events.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/core/port_takeover.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/core/rate_limiter.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/core/request.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/core/response.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/core/router.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/crud/__init__.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/crud/page.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/crud/page_render.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/database/__init__.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/database/adapter.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/database/async_api.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/database/connection.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/database/database_url.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/database/firebird.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/database/mongodb.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/database/mssql.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/database/mysql.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/database/odbc.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/database/pool.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/database/postgres.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/database/sql_translator.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/database/sqlite.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/debug/__init__.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/debug/error_overlay.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/dev_admin/metrics.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/dev_admin/plan.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/dev_admin/project_index.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/docs.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/docstore/__init__.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/dotenv/__init__.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/env.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/frond/FROND.md +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/frond/__init__.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/frond/compiler.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/frond/engine.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/frond/parser.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/gallery/auth/meta.json +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/gallery/auth/src/routes/api/gallery_auth.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/gallery/database/meta.json +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/gallery/database/src/routes/api/gallery_db.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/gallery/error-overlay/meta.json +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/gallery/error-overlay/src/routes/api/gallery_crash.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/gallery/orm/meta.json +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/gallery/orm/src/orm/Product.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/gallery/orm/src/routes/api/gallery_products.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/gallery/queue/meta.json +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/gallery/queue/src/routes/api/gallery_queue.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/gallery/rest-api/meta.json +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/gallery/rest-api/src/routes/api/gallery_hello.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/gallery/templates/meta.json +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/gallery/templates/src/routes/gallery_page.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/gallery/templates/src/templates/gallery_page.twig +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/graph/__init__.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/graph/adapter.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/graph/adapters/__init__.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/graph/adapters/arango.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/graph/adapters/bolt.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/graph/adapters/ultipa.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/graph/graph_url.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/graphql/__init__.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/i18n/__init__.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/mcp/protocol.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/mcp/tools.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/messenger/__init__.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/migration/__init__.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/migration/runner.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/mqtt/__init__.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/mqtt/message.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/orm/__init__.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/orm/async_api.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/orm/collection.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/orm/fields.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/orm/model.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/orm/point.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/public/THIRD-PARTY-NOTICES.md +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/public/__feedback/widget.js +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/public/bundled-component-provenance.json +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/public/css/tina4.css +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/public/css/tina4.min.css +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/public/favicon.ico +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/public/images/logo.svg +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/public/images/tina4-logo-icon.webp +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/public/js/frond.js +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/public/js/frond.min.js +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/public/js/tina4-dev-admin-split.html +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/public/js/tina4-dev-admin.min.js +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/public/js/tina4.min.js +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/public/js/tina4js.min.js +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/public/licenses/swagger-ui-3.10.0-original-notice.txt +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/public/licenses/swagger-ui-5.17.14-NOTICE.txt +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/public/licenses/swagger-ui-Apache-2.0.txt +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/public/licenses/tina4-css-MIT.txt +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/public/licenses/tina4-dev-admin-components.json +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/public/licenses/tina4-dev-admin-third-party.txt +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/public/licenses/tina4-js-MIT.txt +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/public/swagger/index.html +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/public/swagger/oauth2-redirect.html +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/push/__init__.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/push/_base.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/push/_cryptography.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/push/_libcrypto.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/query_builder/__init__.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/queue/__init__.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/queue/amqp_url.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/queue/job.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/queue/kafka_backend.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/queue/lite_backend.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/queue/mongo_backend.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/queue/rabbitmq_backend.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/queue/topic_dead_letter.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/queue_backends/__init__.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/queue_backends/mongo_backend.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/queue_backends/rabbitmq_backend.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/realtime/__init__.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/realtime/models/Attachment.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/realtime/models/Channel.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/realtime/models/ChannelMember.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/realtime/models/Message.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/realtime/models/Workspace.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/realtime/models/__init__.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/realtime/s3_client.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/realtime/storage.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/seeder/__init__.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/service/__init__.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/session/__init__.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/session_handlers/__init__.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/session_handlers/memcached_handler.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/session_handlers/mongodb_handler.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/session_handlers/redis_handler.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/session_handlers/valkey_handler.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/sso.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/ssrf.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/swagger/__init__.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/tcp/__init__.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/templates/components/crud.twig +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/templates/crud/form.twig +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/templates/crud/modals.twig +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/templates/crud/page.twig +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/templates/crud/table.twig +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/templates/docker/distroless/Dockerfile +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/templates/docker/poetry/Dockerfile +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/templates/docker/python/Dockerfile +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/templates/docker/uv/Dockerfile +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/templates/errors/302.twig +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/templates/errors/401.twig +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/templates/errors/403.twig +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/templates/errors/404.twig +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/templates/errors/500.twig +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/templates/errors/502.twig +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/templates/errors/503.twig +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/templates/errors/base.twig +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/templates/frontend/README.md +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/templates/readme.md +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/test/__init__.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/translations/af/LC_MESSAGES/messages.mo +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/translations/af/LC_MESSAGES/messages.po +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/translations/en/LC_MESSAGES/messages.mo +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/translations/en/LC_MESSAGES/messages.po +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/translations/es/LC_MESSAGES/messages.mo +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/translations/es/LC_MESSAGES/messages.po +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/translations/fr/LC_MESSAGES/messages.mo +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/translations/fr/LC_MESSAGES/messages.po +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/translations/ja/LC_MESSAGES/messages.mo +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/translations/ja/LC_MESSAGES/messages.po +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/translations/zh/LC_MESSAGES/messages.mo +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/translations/zh/LC_MESSAGES/messages.po +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/validator/__init__.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/websocket/__init__.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/websocket/backplane.py +0 -0
- {tina4_python-3.13.161 → tina4_python-3.13.163}/tina4_python/wsdl/__init__.py +0 -0
|
@@ -37,6 +37,7 @@ the wrong one is a loud ``ImportError``/``AttributeError``, never a silent
|
|
|
37
37
|
change of call semantics.
|
|
38
38
|
"""
|
|
39
39
|
|
|
40
|
+
from tina4_python._testing_async import _AsyncRunner, _AsyncRunnerError, _RunAborted
|
|
40
41
|
import sys
|
|
41
42
|
import traceback
|
|
42
43
|
|
|
@@ -88,12 +89,40 @@ def tests(*assertions):
|
|
|
88
89
|
|
|
89
90
|
# ── Runner ──────────────────────────────────────────────────────────
|
|
90
91
|
|
|
91
|
-
def run_all(quiet: bool = False, failfast: bool = False) -> dict:
|
|
92
|
+
def run_all(quiet: bool = False, failfast: bool = False, timeout: float | None = 30.0) -> dict:
|
|
92
93
|
"""Discover and run every ``@tests``-decorated function.
|
|
93
94
|
|
|
94
95
|
Returns a dict with keys ``passed``, ``failed``, ``errors``, ``details``.
|
|
96
|
+
|
|
97
|
+
An ``async def`` test function is awaited, and judged on what it returns;
|
|
98
|
+
so is any test function whose call returns an awaitable (a coroutine, a
|
|
99
|
+
Future, an object with ``__await__``).
|
|
100
|
+
Every async test in one run shares ONE event loop, created here and closed
|
|
101
|
+
when the run ends, so an object bound to a loop (an ``asyncio.Queue``, a
|
|
102
|
+
pooled connection) works across assertions. Called from inside a running
|
|
103
|
+
event loop, an async test cannot be awaited without blocking that loop, so
|
|
104
|
+
it is reported as an error asking for a synchronous caller. An async test
|
|
105
|
+
still awaiting after ``timeout`` seconds (``None``: no limit) is cancelled
|
|
106
|
+
and reported as an error, after up to one second for its cleanup. The
|
|
107
|
+
timeout cannot pre-empt code that never yields (``time.sleep`` inside an
|
|
108
|
+
``async def``). A test that is still running after that second (it ignored
|
|
109
|
+
its cancellation) is abandoned: anything it raises afterwards, such as a
|
|
110
|
+
``SystemExit``, is no longer attributed to it and ends the run as it would
|
|
111
|
+
from a sync test; the same holds for a task a test leaves running. A test
|
|
112
|
+
that tampers with the runner's own loop internals is outside these
|
|
113
|
+
guarantees.
|
|
95
114
|
"""
|
|
96
115
|
results = {"passed": 0, "failed": 0, "errors": 0, "details": []}
|
|
116
|
+
runner = _AsyncRunner(timeout)
|
|
117
|
+
try:
|
|
118
|
+
return _run_all(results, runner, quiet, failfast)
|
|
119
|
+
except _RunAborted as stop:
|
|
120
|
+
raise stop.args[0] from None
|
|
121
|
+
finally:
|
|
122
|
+
runner.close()
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def _run_all(results: dict, runner: "_AsyncRunner", quiet: bool, failfast: bool) -> dict:
|
|
97
126
|
|
|
98
127
|
for entry in _registry:
|
|
99
128
|
fn = entry["fn"]
|
|
@@ -106,7 +135,7 @@ def run_all(quiet: bool = False, failfast: bool = False) -> dict:
|
|
|
106
135
|
for assertion in entry["assertions"]:
|
|
107
136
|
label = _assertion_label(assertion, name)
|
|
108
137
|
try:
|
|
109
|
-
_run_assertion(fn, assertion)
|
|
138
|
+
_run_assertion(fn, assertion, runner)
|
|
110
139
|
results["passed"] += 1
|
|
111
140
|
results["details"].append({"name": label, "status": "passed"})
|
|
112
141
|
if not quiet:
|
|
@@ -135,36 +164,27 @@ def run_all(quiet: bool = False, failfast: bool = False) -> dict:
|
|
|
135
164
|
|
|
136
165
|
# ── Internals ───────────────────────────────────────────────────────
|
|
137
166
|
|
|
138
|
-
|
|
167
|
+
|
|
168
|
+
def _run_assertion(fn, assertion: dict, runner: _AsyncRunner):
|
|
139
169
|
atype = assertion["type"]
|
|
140
170
|
args = assertion["args"]
|
|
141
171
|
|
|
142
172
|
if atype == "equal":
|
|
143
|
-
result = fn
|
|
173
|
+
result = runner.call(fn, args)
|
|
144
174
|
expected = assertion["expected"]
|
|
145
175
|
if result != expected:
|
|
146
176
|
raise AssertionError(f"expected {expected!r}, got {result!r}")
|
|
147
177
|
|
|
148
178
|
elif atype == "raises":
|
|
149
|
-
|
|
150
|
-
try:
|
|
151
|
-
fn(*args)
|
|
152
|
-
except exc_class:
|
|
153
|
-
return # success
|
|
154
|
-
except Exception as other:
|
|
155
|
-
raise AssertionError(
|
|
156
|
-
f"expected {exc_class.__name__}, got {type(other).__name__}: {other}"
|
|
157
|
-
)
|
|
158
|
-
else:
|
|
159
|
-
raise AssertionError(f"expected {exc_class.__name__} to be raised")
|
|
179
|
+
_run_raises(fn, args, assertion["exception"], runner)
|
|
160
180
|
|
|
161
181
|
elif atype == "true":
|
|
162
|
-
result = fn
|
|
182
|
+
result = runner.call(fn, args)
|
|
163
183
|
if not result:
|
|
164
184
|
raise AssertionError(f"expected truthy, got {result!r}")
|
|
165
185
|
|
|
166
186
|
elif atype == "false":
|
|
167
|
-
result = fn
|
|
187
|
+
result = runner.call(fn, args)
|
|
168
188
|
if result:
|
|
169
189
|
raise AssertionError(f"expected falsy, got {result!r}")
|
|
170
190
|
|
|
@@ -172,6 +192,21 @@ def _run_assertion(fn, assertion: dict):
|
|
|
172
192
|
raise ValueError(f"unknown assertion type: {atype!r}")
|
|
173
193
|
|
|
174
194
|
|
|
195
|
+
def _run_raises(fn, args, exc_class: type, runner: _AsyncRunner):
|
|
196
|
+
try:
|
|
197
|
+
runner.call(fn, args)
|
|
198
|
+
except (_AsyncRunnerError, _RunAborted):
|
|
199
|
+
raise # the runner failed or the run is ending: never a pass
|
|
200
|
+
except exc_class:
|
|
201
|
+
return # success
|
|
202
|
+
except Exception as other:
|
|
203
|
+
raise AssertionError(
|
|
204
|
+
f"expected {exc_class.__name__}, got {type(other).__name__}: {other}"
|
|
205
|
+
)
|
|
206
|
+
else:
|
|
207
|
+
raise AssertionError(f"expected {exc_class.__name__} to be raised")
|
|
208
|
+
|
|
209
|
+
|
|
175
210
|
def _assertion_label(assertion: dict, fn_name: str) -> str:
|
|
176
211
|
atype = assertion["type"]
|
|
177
212
|
args = assertion["args"]
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# Copyright (c) 2026 Code Infinity
|
|
2
|
+
# SPDX-License-Identifier: MPL-2.0
|
|
3
|
+
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
6
|
+
"""Awaiting async inline tests for :mod:`tina4_python.Testing`.
|
|
7
|
+
|
|
8
|
+
One event loop per ``run_all()``; every test's awaitable runs as a task the
|
|
9
|
+
runner watches from outside the loop, so nothing a test does can cancel, hang
|
|
10
|
+
or abort the runner itself.
|
|
11
|
+
"""
|
|
12
|
+
import asyncio
|
|
13
|
+
import inspect
|
|
14
|
+
import numbers
|
|
15
|
+
|
|
16
|
+
# How long a cancelled test task gets to finish before the runner moves on.
|
|
17
|
+
_CANCEL_GRACE = 1.0
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class _AsyncRunnerError(RuntimeError):
|
|
21
|
+
"""The runner could not run a test, which is never the test's own exception."""
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class _RunAborted(BaseException):
|
|
25
|
+
"""A SystemExit / KeyboardInterrupt that did not come from the test being
|
|
26
|
+
judged (a Ctrl-C, or a task an earlier test left running). It ends the run,
|
|
27
|
+
as it would from a sync test, and no assertion can catch it as its own."""
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _check_timeout(timeout):
|
|
31
|
+
"""Seconds as a float (infinity allowed), or None for no limit."""
|
|
32
|
+
if timeout is None:
|
|
33
|
+
return None
|
|
34
|
+
if isinstance(timeout, bool) or not isinstance(timeout, numbers.Real):
|
|
35
|
+
raise TypeError(f"timeout must be a number of seconds or None, got {timeout!r}")
|
|
36
|
+
try:
|
|
37
|
+
seconds = float(timeout)
|
|
38
|
+
except OverflowError:
|
|
39
|
+
return None # larger than any float: no limit
|
|
40
|
+
if seconds != seconds or seconds < 0:
|
|
41
|
+
raise ValueError(f"timeout must be zero or more seconds, got {timeout!r}")
|
|
42
|
+
return seconds
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _run_for(loop, tasks, timeout) -> None:
|
|
46
|
+
"""Run ``loop`` until every task in ``tasks`` is done or ``timeout`` passes.
|
|
47
|
+
|
|
48
|
+
It waits on a plain future, not a task, so nothing a test does through
|
|
49
|
+
``asyncio.all_tasks()`` (a "cancel every other task" teardown) can reach the
|
|
50
|
+
runner itself. An ordinary exception out of the loop (a test stopped it) is
|
|
51
|
+
the runner's failure, never the test's own exception.
|
|
52
|
+
"""
|
|
53
|
+
pending = [t for t in tasks if not t.done()]
|
|
54
|
+
if not pending:
|
|
55
|
+
return
|
|
56
|
+
waiter = loop.create_future()
|
|
57
|
+
|
|
58
|
+
def wake(_=None, expired=False):
|
|
59
|
+
if not waiter.done() and (expired or all(t.done() for t in pending)):
|
|
60
|
+
waiter.set_result(None)
|
|
61
|
+
|
|
62
|
+
for t in pending:
|
|
63
|
+
t.add_done_callback(wake)
|
|
64
|
+
handle = loop.call_later(timeout, wake, None, True) if timeout is not None else None
|
|
65
|
+
try:
|
|
66
|
+
loop.run_until_complete(waiter)
|
|
67
|
+
except (Exception, asyncio.CancelledError) as exc:
|
|
68
|
+
raise _AsyncRunnerError(f"the test runner's event loop failed: {exc!r}") from exc
|
|
69
|
+
finally:
|
|
70
|
+
if handle is not None:
|
|
71
|
+
handle.cancel()
|
|
72
|
+
for t in pending:
|
|
73
|
+
t.remove_done_callback(wake)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def _settle(loop, tasks) -> None:
|
|
77
|
+
"""Give ``tasks`` the cancel grace while the run is closing. Results are
|
|
78
|
+
already in: a SystemExit from a task an earlier test abandoned must not turn
|
|
79
|
+
a failed run into exit status 0, nor skip the cleanup of the others."""
|
|
80
|
+
try:
|
|
81
|
+
_run_for(loop, tasks, _CANCEL_GRACE)
|
|
82
|
+
except (_AsyncRunnerError, SystemExit):
|
|
83
|
+
pass
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class _AsyncRunner:
|
|
87
|
+
"""Runs awaitable test results to completion on one loop per run_all()."""
|
|
88
|
+
|
|
89
|
+
def __init__(self, timeout: float | None = 30.0):
|
|
90
|
+
self._timeout = _check_timeout(timeout)
|
|
91
|
+
self._loop = None
|
|
92
|
+
|
|
93
|
+
def call(self, fn, args):
|
|
94
|
+
"""Call ``fn(*args)``; an awaitable result is awaited and its value returned."""
|
|
95
|
+
result = fn(*args)
|
|
96
|
+
if not inspect.isawaitable(result):
|
|
97
|
+
return result
|
|
98
|
+
try:
|
|
99
|
+
asyncio.get_running_loop()
|
|
100
|
+
except RuntimeError:
|
|
101
|
+
pass
|
|
102
|
+
else:
|
|
103
|
+
if inspect.iscoroutine(result):
|
|
104
|
+
result.close() # never started: no "was never awaited" warning
|
|
105
|
+
raise _AsyncRunnerError(
|
|
106
|
+
"async test function: run_all() was called from inside a running "
|
|
107
|
+
"event loop and cannot await it; call run_all() from synchronous code"
|
|
108
|
+
)
|
|
109
|
+
return self._await(result)
|
|
110
|
+
|
|
111
|
+
def _await(self, result):
|
|
112
|
+
if self._loop is None:
|
|
113
|
+
self._loop = asyncio.new_event_loop()
|
|
114
|
+
# A task watched from outside, not wait_for: a TimeoutError the test
|
|
115
|
+
# raises itself must reach the assertion as the test's own exception.
|
|
116
|
+
try:
|
|
117
|
+
task = asyncio.ensure_future(result, loop=self._loop)
|
|
118
|
+
except Exception as exc: # a foreign-loop future, a broken task factory
|
|
119
|
+
raise _AsyncRunnerError(f"could not schedule the async test: {exc!r}") from exc
|
|
120
|
+
try:
|
|
121
|
+
_run_for(self._loop, [task], self._timeout)
|
|
122
|
+
except _AsyncRunnerError:
|
|
123
|
+
self._stop(task) # e.g. the test stopped the loop: it must not run on
|
|
124
|
+
raise
|
|
125
|
+
except BaseException as exc:
|
|
126
|
+
# A SystemExit / KeyboardInterrupt out of the loop is the test's own
|
|
127
|
+
# only when its task finished with exactly that exception.
|
|
128
|
+
if task.done() and not task.cancelled() and task.exception() is exc:
|
|
129
|
+
raise
|
|
130
|
+
self._stop(task)
|
|
131
|
+
raise _RunAborted(exc) from None
|
|
132
|
+
return self._judge(task)
|
|
133
|
+
|
|
134
|
+
def _stop(self, task):
|
|
135
|
+
if not task.done():
|
|
136
|
+
task.cancel()
|
|
137
|
+
try:
|
|
138
|
+
_run_for(self._loop, [task], _CANCEL_GRACE)
|
|
139
|
+
except _AsyncRunnerError:
|
|
140
|
+
pass
|
|
141
|
+
|
|
142
|
+
def _judge(self, task):
|
|
143
|
+
if not task.done():
|
|
144
|
+
# Bounded: a test that swallows CancelledError must not hang the run.
|
|
145
|
+
self._stop(task)
|
|
146
|
+
raise _AsyncRunnerError(f"async test function did not finish within {self._timeout}s")
|
|
147
|
+
if task.cancelled():
|
|
148
|
+
# The test cancelled itself (raised CancelledError). That is a
|
|
149
|
+
# BaseException and would abort the whole run; report it instead.
|
|
150
|
+
raise _AsyncRunnerError("async test function was cancelled")
|
|
151
|
+
return task.result()
|
|
152
|
+
|
|
153
|
+
def close(self):
|
|
154
|
+
if self._loop is None:
|
|
155
|
+
return
|
|
156
|
+
loop, self._loop = self._loop, None
|
|
157
|
+
try:
|
|
158
|
+
loop.set_task_factory(None) # a test may have installed a broken one
|
|
159
|
+
pending = asyncio.all_tasks(loop)
|
|
160
|
+
for task in pending:
|
|
161
|
+
task.cancel()
|
|
162
|
+
# Twice: a SystemExit from one abandoned task stops the loop before
|
|
163
|
+
# the others have run their cleanup.
|
|
164
|
+
_settle(loop, pending)
|
|
165
|
+
_settle(loop, pending)
|
|
166
|
+
# Bounded the same way: a generator whose cleanup swallows
|
|
167
|
+
# CancelledError must not hang the run.
|
|
168
|
+
shutdown = loop.create_task(loop.shutdown_asyncgens())
|
|
169
|
+
_settle(loop, [shutdown])
|
|
170
|
+
shutdown.cancel()
|
|
171
|
+
_settle(loop, [shutdown])
|
|
172
|
+
finally:
|
|
173
|
+
loop.close()
|
|
@@ -495,12 +495,12 @@ def generate_context(tool_name: str = "claude-code") -> str:
|
|
|
495
495
|
|
|
496
496
|
@get("/api/users")
|
|
497
497
|
async def list_users(request, response):
|
|
498
|
-
return response({
|
|
498
|
+
return response({"users": []})
|
|
499
499
|
|
|
500
500
|
@post("/api/users")
|
|
501
501
|
@noauth()
|
|
502
502
|
async def create_user(request, response):
|
|
503
|
-
return response({
|
|
503
|
+
return response({"created": request.body["name"]}, 201)'''
|
|
504
504
|
|
|
505
505
|
_orm_example = '''from tina4_python.orm import ORM, IntegerField, StringField
|
|
506
506
|
|
|
@@ -317,6 +317,18 @@ def _cors_warn_once(reason: str, message: str) -> None:
|
|
|
317
317
|
logging.getLogger("tina4").warning(message)
|
|
318
318
|
|
|
319
319
|
|
|
320
|
+
_CORS_ENV_KEYS = (
|
|
321
|
+
"TINA4_CORS_ORIGINS", "TINA4_CORS_METHODS", "TINA4_CORS_HEADERS",
|
|
322
|
+
"TINA4_CORS_MAX_AGE", "TINA4_CORS_CREDENTIALS",
|
|
323
|
+
)
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
def cors_env() -> tuple:
|
|
327
|
+
"""The TINA4_CORS_* settings ``CorsMiddleware`` reads, as they stand now."""
|
|
328
|
+
return tuple(os.environ.get(key) for key in _CORS_ENV_KEYS)
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
|
|
320
332
|
class CorsMiddleware:
|
|
321
333
|
"""CORS handler — reads config from env, injects headers.
|
|
322
334
|
|
|
@@ -360,6 +372,10 @@ class CorsMiddleware:
|
|
|
360
372
|
return request, response
|
|
361
373
|
|
|
362
374
|
def __init__(self):
|
|
375
|
+
# What this instance was built from; the server's singleton is rebuilt
|
|
376
|
+
# in place when the environment no longer matches it (a policy set
|
|
377
|
+
# only in .env).
|
|
378
|
+
self._env_read = cors_env()
|
|
363
379
|
# Default is EMPTY, not "*" — deny by default (ADR-0018).
|
|
364
380
|
self.origins = os.environ.get("TINA4_CORS_ORIGINS", "")
|
|
365
381
|
self.methods = os.environ.get(
|
|
@@ -373,6 +389,9 @@ class CorsMiddleware:
|
|
|
373
389
|
self.credentials = os.environ.get(
|
|
374
390
|
"TINA4_CORS_CREDENTIALS", "false"
|
|
375
391
|
).lower() in ("true", "1", "yes")
|
|
392
|
+
# Everything as built, so a refresh can tell the instance was changed
|
|
393
|
+
# by hand (a policy field, or an override set on it) and leave it be.
|
|
394
|
+
self._as_built = dict(vars(self))
|
|
376
395
|
|
|
377
396
|
@property
|
|
378
397
|
def allowed_origins(self) -> list:
|
|
@@ -33,7 +33,9 @@ from tina4_python.core.request import (
|
|
|
33
33
|
)
|
|
34
34
|
from tina4_python.core.response import Response, unsafe_header_reason
|
|
35
35
|
from tina4_python.core.router import Router
|
|
36
|
-
from tina4_python.core.middleware import
|
|
36
|
+
from tina4_python.core.middleware import (
|
|
37
|
+
CorsMiddleware, RateLimiter, SecurityHeadersMiddleware, cors_env,
|
|
38
|
+
)
|
|
37
39
|
from tina4_python.debug import Log, set_request_id, get_request_id, sanitize_request_id, clear_request_id
|
|
38
40
|
from tina4_python import __version__
|
|
39
41
|
|
|
@@ -42,6 +44,27 @@ _cors = CorsMiddleware()
|
|
|
42
44
|
_rate_limiter = RateLimiter()
|
|
43
45
|
|
|
44
46
|
|
|
47
|
+
def _refresh_cors_from_env() -> None:
|
|
48
|
+
"""Re-read TINA4_CORS_* into the CORS singleton if they changed since it was built.
|
|
49
|
+
|
|
50
|
+
``_cors`` is built at import, before any entry point loads ``.env``, so a
|
|
51
|
+
policy set only in ``.env`` was never applied. Every entry point that loads
|
|
52
|
+
``.env`` (``run()``/``asgi()`` via ``_load_project_env``, and ``TestClient``)
|
|
53
|
+
calls this afterwards. The instance is updated in place, so a reference
|
|
54
|
+
held elsewhere stays current. Only a plain ``CorsMiddleware`` that
|
|
55
|
+
is exactly as it was built is touched; anything else is left as it is: a
|
|
56
|
+
subclass, a test double, or an instance changed by hand.
|
|
57
|
+
"""
|
|
58
|
+
if type(_cors) is not CorsMiddleware:
|
|
59
|
+
return
|
|
60
|
+
if getattr(_cors, "_env_read", None) == cors_env():
|
|
61
|
+
return
|
|
62
|
+
as_built = getattr(_cors, "_as_built", None)
|
|
63
|
+
if as_built is None or {k: v for k, v in vars(_cors).items() if k != "_as_built"} != as_built:
|
|
64
|
+
return
|
|
65
|
+
_cors.__dict__.update(vars(CorsMiddleware()))
|
|
66
|
+
|
|
67
|
+
|
|
45
68
|
# ContextVar to signal that the current request is being served on the AI dev port
|
|
46
69
|
_ai_port_ctx: contextvars.ContextVar[bool] = contextvars.ContextVar("_ai_port_ctx", default=False)
|
|
47
70
|
|
|
@@ -3144,6 +3167,7 @@ def _load_project_env() -> None:
|
|
|
3144
3167
|
from tina4_python.dotenv import load_env
|
|
3145
3168
|
load_env(override=False)
|
|
3146
3169
|
_apply_health_path_from_env()
|
|
3170
|
+
_refresh_cors_from_env()
|
|
3147
3171
|
|
|
3148
3172
|
|
|
3149
3173
|
|
|
@@ -4730,13 +4754,12 @@ def run(host: str | None = None, port: int | None = None, no_browser: bool = Fal
|
|
|
4730
4754
|
except OSError:
|
|
4731
4755
|
Log.warning(f"AI port {_ai_port} in use — skipping")
|
|
4732
4756
|
|
|
4733
|
-
#
|
|
4734
|
-
#
|
|
4735
|
-
#
|
|
4736
|
-
#
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
|
|
4757
|
+
# Arm the shutdown signal handlers BEFORE we begin accepting raw-TCP
|
|
4758
|
+
# connections (below). Binding a port that accepts work before graceful
|
|
4759
|
+
# shutdown is wired leaves a window in which a signal kills the process
|
|
4760
|
+
# ungracefully instead of draining — a device that connects the instant
|
|
4761
|
+
# the port opens lands squarely in it (feature 142's SIGTERM-drain
|
|
4762
|
+
# contract). Mirrors Node/PHP/Ruby arming handlers before accept.
|
|
4740
4763
|
loop = asyncio.get_running_loop()
|
|
4741
4764
|
for sig in (signal.SIGINT, signal.SIGTERM):
|
|
4742
4765
|
try:
|
|
@@ -4744,6 +4767,15 @@ def run(host: str | None = None, port: int | None = None, no_browser: bool = Fal
|
|
|
4744
4767
|
except NotImplementedError:
|
|
4745
4768
|
pass # Windows
|
|
4746
4769
|
|
|
4770
|
+
# Raw TCP services (feature 142, ADR-0102 D1) fold into THIS accept loop
|
|
4771
|
+
# — same process as HTTP, so a device gateway and its dashboard share
|
|
4772
|
+
# config, logging, ORM and queue. Started AFTER the handlers above, so a
|
|
4773
|
+
# device connecting the instant the port opens can never catch the
|
|
4774
|
+
# process without a graceful-shutdown handler. Each binds its own port; a
|
|
4775
|
+
# worker that finds the port already bound skips silently (single-owner).
|
|
4776
|
+
from tina4_python import tcp as _tcp_services
|
|
4777
|
+
await _tcp_services.start_all(host)
|
|
4778
|
+
|
|
4747
4779
|
# Start registered background tasks as asyncio tasks. Sync callbacks run
|
|
4748
4780
|
# in a thread pool so they CANNOT block the event loop. The SAME helper
|
|
4749
4781
|
# runs under the production ASGI lifespan (see app()), so a background()
|
|
@@ -4752,63 +4784,92 @@ def run(host: str | None = None, port: int | None = None, no_browser: bool = Fal
|
|
|
4752
4784
|
|
|
4753
4785
|
await shutdown.wait()
|
|
4754
4786
|
|
|
4755
|
-
#
|
|
4756
|
-
#
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
#
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
#
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
# 3. Drain what is already in flight, BOUNDED. wait_closed() on its own
|
|
4770
|
-
# waits forever, so one wedged handler (or one idle WebSocket) used to
|
|
4771
|
-
# hold the process open past any orchestrator's grace period.
|
|
4772
|
-
timeout_seconds = _resolve_shutdown_timeout()
|
|
4787
|
+
# The whole teardown tail is EXCEPTION-SAFE: a throw in ANY step must
|
|
4788
|
+
# degrade to a stderr line and STILL let a handled SIGTERM/SIGINT exit 0
|
|
4789
|
+
# — it may never fatal the process. Two steps below log while they tear
|
|
4790
|
+
# down (the invalid-timeout WARNING in _resolve_shutdown_timeout(), and
|
|
4791
|
+
# the "Server stopped." / Log.reset() finale), so under TINA4_LOG_STRICT
|
|
4792
|
+
# with a failing log sink they RAISE; before this guard that escaped
|
|
4793
|
+
# _serve() → asyncio.run() re-raised → a handled signal exited non-zero,
|
|
4794
|
+
# the exact opposite of the contract. This mirrors PHP Server::cleanup()
|
|
4795
|
+
# (the \Throwable guard that still exit(0)s) and Ruby's teardown. It is
|
|
4796
|
+
# idempotent (the shutdown event is already consumed and _serve() returns
|
|
4797
|
+
# right after) and does NOT touch the production uvicorn/hypercorn/granian
|
|
4798
|
+
# path, which computes the timeout at config time and returns long before
|
|
4799
|
+
# this tail runs.
|
|
4773
4800
|
try:
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
try:
|
|
4780
|
-
await _ws_manager.disconnect_all(
|
|
4781
|
-
code=CLOSE_GOING_AWAY, reason="server shutting down")
|
|
4782
|
-
except Exception as exc: # noqa: BLE001 — never fail the exit
|
|
4783
|
-
Log.error(f"Error closing WebSocket connections on shutdown: {exc}")
|
|
4784
|
-
# Raw TCP services drain their live device connections (firing
|
|
4785
|
-
# on_close) alongside the HTTP drain, within the same deadline.
|
|
4786
|
-
try:
|
|
4787
|
-
await _tcp_services.drain_all()
|
|
4788
|
-
except Exception as exc: # noqa: BLE001 — never fail the exit
|
|
4789
|
-
Log.error(f"Error draining TCP services on shutdown: {exc}")
|
|
4790
|
-
for live_server in live_servers:
|
|
4791
|
-
await live_server.wait_closed()
|
|
4792
|
-
except TimeoutError:
|
|
4793
|
-
Log.warning(
|
|
4794
|
-
f"TINA4_SHUTDOWN_TIMEOUT={timeout_seconds:g}s reached with work still "
|
|
4795
|
-
f"in flight — forcing the remaining connections closed"
|
|
4796
|
-
)
|
|
4801
|
+
# 1. Stop accepting FIRST. A connection that arrives after the signal
|
|
4802
|
+
# must get a clean CONNECTION REFUSED — not a 503, not a TCP reset.
|
|
4803
|
+
live_servers = [
|
|
4804
|
+
s for s in (ai_server, server, *loopback_servers) if s is not None
|
|
4805
|
+
]
|
|
4797
4806
|
for live_server in live_servers:
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
4807
|
+
live_server.close()
|
|
4808
|
+
# Raw TCP listeners stop accepting at the same moment as HTTP.
|
|
4809
|
+
_tcp_services.stop_accepting_all()
|
|
4810
|
+
|
|
4811
|
+
# 2. Stop background work.
|
|
4812
|
+
for t in bg_tasks:
|
|
4813
|
+
t.cancel()
|
|
4814
|
+
|
|
4815
|
+
# 3. Drain what is already in flight, BOUNDED. wait_closed() on its
|
|
4816
|
+
# own waits forever, so one wedged handler (or one idle WebSocket)
|
|
4817
|
+
# used to hold the process open past any orchestrator's grace
|
|
4818
|
+
# period.
|
|
4819
|
+
timeout_seconds = _resolve_shutdown_timeout()
|
|
4820
|
+
try:
|
|
4821
|
+
async with asyncio.timeout(timeout_seconds):
|
|
4822
|
+
# A live WebSocket never drains by itself — tell it we are
|
|
4823
|
+
# going away (RFC 6455 close code 1001) so the client
|
|
4824
|
+
# reconnects elsewhere instead of seeing the socket vanish. A
|
|
4825
|
+
# dead peer must not turn a clean exit 0 into a crash on the
|
|
4826
|
+
# way out.
|
|
4827
|
+
try:
|
|
4828
|
+
await _ws_manager.disconnect_all(
|
|
4829
|
+
code=CLOSE_GOING_AWAY, reason="server shutting down")
|
|
4830
|
+
except Exception as exc: # noqa: BLE001 — never fail the exit
|
|
4831
|
+
Log.error(f"Error closing WebSocket connections on shutdown: {exc}")
|
|
4832
|
+
# Raw TCP services drain their live device connections (firing
|
|
4833
|
+
# on_close) alongside the HTTP drain, within the same deadline.
|
|
4834
|
+
try:
|
|
4835
|
+
await _tcp_services.drain_all()
|
|
4836
|
+
except Exception as exc: # noqa: BLE001 — never fail the exit
|
|
4837
|
+
Log.error(f"Error draining TCP services on shutdown: {exc}")
|
|
4838
|
+
for live_server in live_servers:
|
|
4839
|
+
await live_server.wait_closed()
|
|
4840
|
+
except TimeoutError:
|
|
4841
|
+
Log.warning(
|
|
4842
|
+
f"TINA4_SHUTDOWN_TIMEOUT={timeout_seconds:g}s reached with work still "
|
|
4843
|
+
f"in flight — forcing the remaining connections closed"
|
|
4844
|
+
)
|
|
4845
|
+
for live_server in live_servers:
|
|
4846
|
+
# Python 3.13+. On 3.12 the tasks are cancelled by
|
|
4847
|
+
# asyncio.run's own teardown instead, which still gets us out.
|
|
4848
|
+
abort_clients = getattr(live_server, "abort_clients", None)
|
|
4849
|
+
if abort_clients is not None:
|
|
4850
|
+
abort_clients()
|
|
4851
|
+
|
|
4852
|
+
# 4. Release the resources the OS would otherwise reap for us.
|
|
4853
|
+
_close_bound_databases()
|
|
4854
|
+
_executor.shutdown(wait=False, cancel_futures=True)
|
|
4855
|
+
Log.info("Server stopped.")
|
|
4856
|
+
# Graceful shutdown owns the final call to reset() (Decision 24 /
|
|
4857
|
+
# LOG-I02): flush+close owned sinks AFTER the shutdown record above is
|
|
4858
|
+
# written, exactly once.
|
|
4859
|
+
Log.reset()
|
|
4860
|
+
except Exception as teardown_error: # noqa: BLE001 — a handled signal MUST exit 0
|
|
4861
|
+
# A teardown step threw (e.g. a strict-mode log sink that fails to
|
|
4862
|
+
# write). Degrade to a best-effort stderr line and fall through to a
|
|
4863
|
+
# clean exit — never re-raise, which would fatal a handled signal.
|
|
4864
|
+
try:
|
|
4865
|
+
print(
|
|
4866
|
+
f"tina4: shutdown teardown degraded ({teardown_error!r}) — "
|
|
4867
|
+
f"exiting 0",
|
|
4868
|
+
file=sys.stderr,
|
|
4869
|
+
flush=True,
|
|
4870
|
+
)
|
|
4871
|
+
except Exception:
|
|
4872
|
+
pass
|
|
4812
4873
|
|
|
4813
4874
|
try:
|
|
4814
4875
|
asyncio.run(_serve())
|