Spaces:
Runtime error
Runtime error
| import logging | |
| import threading | |
| import time | |
| from .config import Settings | |
| from .logging_setup import configure_logging | |
| from .model_store import ModelStore | |
| from .worker import RealtimeWorker | |
| logger = logging.getLogger("celery-space.runtime") | |
| def start_worker(settings): | |
| worker = RealtimeWorker(settings) | |
| thread = threading.Thread(target=worker.run_forever, name="supabase-realtime-worker", daemon=True) | |
| thread.start() | |
| return thread | |
| def start_worker_and_block_if_needed(): | |
| settings = Settings.from_env() | |
| configure_logging(settings.log_level) | |
| model_store = ModelStore(settings) | |
| model_status = model_store.describe() | |
| logger.info( | |
| "model bucket source=%s mount_path=%s mount_exists=%s protexa_instruction_path=%s ready=%s missing=%s", | |
| model_status["bucket_id"], | |
| model_status["mount_path"], | |
| model_status["mount_exists"], | |
| model_status["protexa_instruction_path"], | |
| model_status["protexa_instruction_ready"], | |
| model_status["missing_instruction_files"], | |
| ) | |
| start_worker(settings) | |
| if settings.hang_after_worker_start: | |
| logger.info("worker thread started; intentionally blocking ASGI import so Space remains Starting") | |
| while True: | |
| time.sleep(3600) | |