cit-is-bot-backend/server/main.py

22 строки
431 B
Python

import contextlib
import time
import threading
import uvicorn
class Server(uvicorn.Server):
@contextlib.contextmanager
def run_in_thread(self):
thread = threading.Thread(
target=self.run,
)
thread.start()
try:
while not self.started:
time.sleep(1e-3)
yield
finally:
self.should_exit = True
thread.join()