Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django, Ajax long polling, Postgresql: idle transaction

I implemented a chat, using ajax long polling and Gevent. To read, the client ajax the update view and wait with Gevent.event.wait for an update.

Problem: The Postgresql transaction opened by Django at the beginning of a request (to get session information) isn't closed until the end of the request. And those idle transactions take a lot of memory.

What would be the cleanest way to close the Postgresql transaction without closing the request ? I'm currently sending the request_finished signal manually but it feels like a hack.

like image 453
Ashe Avatar asked Feb 15 '12 23:02

Ashe


1 Answers

The way you're doing it is probably the the best way within the framework of your hack anyway. Is there any reason you're trying to shoe-horn long-poll into the request-response process instead of using something like django-socketio?

like image 170
Thomas Avatar answered Oct 23 '22 14:10

Thomas