Skip to content

Commit

Permalink
Fix: timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
sverben committed Jan 21, 2024
1 parent 705ea66 commit 7fb8cfa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def create_announcement(db: Session, announcement: schemas.AnnouncementCreate):
"to": tokens,
"title": announcement.title,
"body": announcement.description
})
}, timeout=10)
return db_announcement


Expand Down
8 changes: 8 additions & 0 deletions app/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,11 @@
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)

Base = declarative_base()


def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()
10 changes: 1 addition & 9 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,12 @@
import models
import schemas
from auth import get_user
from database import engine, SessionLocal
from database import engine, get_db

models.Base.metadata.create_all(bind=engine)
app = FastAPI()


def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()


@app.post("/private/announcements", response_model=schemas.Announcement)
def create_announcement(announcement: schemas.AnnouncementCreate, db: Session = Depends(get_db)):
return crud.create_announcement(db=db, announcement=announcement)
Expand Down

0 comments on commit 7fb8cfa

Please sign in to comment.