Skip to content
Discussion options

You must be logged in to vote

Closing the connection seems to help in all of the mentioned FastAPI versions (at least on my machine).

Edit: This does not require the endpoints to be async def functions.

before

@app.get("/jobs/{job_id}")
def get_job(job_id: int = Path(...)):
    conn = ENGINE.connect()
    stmt = select([T]).with_for_update().where(T.c.id == job_id)
    row = conn.execute(stmt).fetchone()
    if row is None:
        # This exception that is raised in the first test causes the second test to
        # hang during its setup.
        # If we do "return None" instead, the second test will be run.
        # return None
        raise HTTPException(404, f'Job with ID "{job_id}" not found')
    return row

after

@

Replies: 5 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by YuriiMotov
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question or problem question-migrate
3 participants
Converted from issue

This discussion was converted from issue #4249 on February 27, 2023 22:13.