I have a seemingly straightforward situation, but I can’t find a straightforward solution.
I am using sqlalchemy to query postgres. If client timeout occurs, I would like to stop / cancel long postgres requests from another thread. The stream has access to the Session or Connection object.
At this point I tried:
session.bind.raw_connection().close()
and
session.connection().close()
and
session.close
and
session.transaction.close()
But no matter what I try, the postgres request continues to the end. I know this by watching pg in top. Isn’t it so easy to do? Am I missing something? Is this impossible without receiving a pid and sending a stop signal directly?
python django postgresql sqlalchemy
Cody django
source share