+ Some thread debugging

This commit is contained in:
Phil Zhitnikov 2024-08-02 16:21:26 +04:00
parent 7571373443
commit 53771e53f5

View File

@ -1,13 +1,32 @@
from chain_service.logging import setup_logging import logging
import threading
from fastapi import FastAPI from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware from fastapi.middleware.cors import CORSMiddleware
from chain_service.logging import setup_logging
from chain_service.controllers.__main__ import setup_controllers from chain_service.controllers.__main__ import setup_controllers
setup_logging() setup_logging()
application = FastAPI() application = FastAPI()
logging.basicConfig(level=logging.DEBUG)
# Subclass threading.Thread for logging
class DebugThread(threading.Thread):
def __init__(self, *args, **kwargs):
logging.debug(f"Creating thread {args} {kwargs}")
super().__init__(*args, **kwargs)
def _delete(self):
logging.debug(f"Deleting thread {self.name}")
super()._delete()
threading.Thread = DebugThread
application.add_middleware( application.add_middleware(
CORSMiddleware, CORSMiddleware,
allow_origins=["http://localhost:5173"], allow_origins=["http://localhost:5173"],