Fixing handling of errors in green communication
От | Daniele Varrazzo |
---|---|
Тема | Fixing handling of errors in green communication |
Дата | |
Msg-id | CA+mi_8auY6QsNuFuksw4rvkGJ-_MqcKScd-NKz_3cZ9ENZwccQ@mail.gmail.com обсуждение исходный текст |
Список | psycopg |
Hello, Ticket #113 shows psycopg blocked because of an error during async communication with green threads http://psycopg.lighthouseapp.com/projects/62710/tickets/113-psycopg2-eventlet-connection-hang We have that clumsy function psyco_clear_result_blocking() in green.c that tries to put the connection back in a working state after an error in the callback (whick could be either a python error or more likely a network problem). But because it is blocking it stops other greenlets to run. I've tried sending a PQcancel instead but it is blocking as well. Another suggestion I've been given is to use PQreset in the nonblocking version, but it would put the program in an unexpected state: the user would find an established connection but with eventual configuration made in Python discarded. So for the moment I think the best solution is to close the connection if there is an error in the callback (meaning an error in the communication, not an error in a query: these ones are handled normally). This would put a Python program in the relatively normal state of dealing a broken connection: a long-living program may already be able to cope with this eventuality; a short-lived one would be at least responsive to ctrl-c (if the network is down the blocking PQfunctions make the interpreter unresponsive to SIGINT). Suggestions for better solutions are well accepted. However discarding a connection when we have lost communication and we don't know in which state it is anymore seems a reasonable one. The solution (together with a test program to test with failures in green querying) is currently living in the fix-113 branch of my repos. -- Daniele
В списке psycopg по дате отправления: