Inércia Sensorial

2021-01-02

Django PostgreSQL used session on Github Actions test error

Filed under: Python — Tags: , , , — inerte @ 16:26

If you’re using the PostgreSQL service on Github Actions as a backend database for your Django tests, you might encounter the following error on any particular test:

django.db.utils.OperationalError: database "test_name" is being accessed by other users
DETAIL:  There is 1 other session using the database.

And the following at the end of your test run:

RuntimeError: generator didn't stop after throw()

The problem is that Django reuses the database connection, and while locally my tests were passing, on Github Actions even though the all tests were passing, somehow a connection to the database created by the tests was still open, and I was getting the error above.

The solution is simple, set CONN_MAX_AGE to 0 (or conn_max_age if you use dj_database_url) on your DATABASES settings when running on Github Actions.

1 Comment »

  1. Então o criador desse tech blog foi quem criou o “Quem Perturba”?

    Vi agora que o serviço está fora do ar e redirecionando pra cá.

    Se for, valeu enquanto durou! Sucesso nos futuros projetos!

    Comment by J.J.Mendes — 2021-01-11 @ 16:36

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress