Skip to content

Commit

Permalink
fix: Handle bulb initialization failure gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
guhyun9454 committed Jun 12, 2024
1 parent 5354d9d commit 652c1e1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions backend/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,20 @@ def ndarray_to_b64(img):
@asynccontextmanager
async def lifespan(app: FastAPI):
# 애플리케이션 시작 시 실행할 코드
await seats_manager.initialize_bulbs()
print("initializing bulbs...")
try:
await seats_manager.initialize_bulbs()
print("initialization succeeds!")
except Exception as e:
print(f"Bulb initialization failed: {e}. Running without bulbs.")
seats_manager.bulb_manager = None

yield

# 애플리케이션 종료 시 실행할 코드
print("Application is shutting down...")
await seats_manager.disable_bulbs()
if seats_manager.bulb_manager:
await seats_manager.disable_bulbs()

app = FastAPI(lifespan=lifespan)

Expand Down

0 comments on commit 652c1e1

Please sign in to comment.