Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

166
Views
FastAPI db query stuck. Kubernetes

I have one small app that use fastapi. The problem is when I deploy it to my server and trying to make a post request to route which contains some database operations, it just stuck and gives me 504 error. But on my local machine it working well.

Here is how my db connecting:

app.add_event_handler("startup", tasks.create_start_app_handler(app))
app.add_event_handler("shutdown", tasks.create_stop_app_handler(app))

I tried to revert db connection from startup application to creation of this connection with closing it in different route to test and its worked. Like:

@app.get("/")
async def create_item():
    engine = create_engine(
        DB_URL
    )
    SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)

    Base = declarative_base()

    t = engine.execute('SELECT * FROM auth_user').fetchone()

    engine.dispose()
    return t

How it's depend on events? Versions of postgresql are different, but I don't think it's because of it.

Currently I have deployment with 2 pods running in it. When I use psql command I can connect normally. So it only stuck in application, not it pod.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

If anyone finds the same, I fixed it by updating pgpoll from 4.2.2 to the latest.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!