mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-11 03:26:37 +03:00
- Hard limit on the connection.notices list to avoid them
growing indefinitely. Notices are treated as a queue: when the queue is full drop the oldest notice.
This commit is contained in:
parent
e1dd9ca843
commit
277f57ffb0
|
@ -36,6 +36,9 @@ extern "C" {
|
|||
#define CONN_STATUS_SYNC 3
|
||||
#define CONN_STATUS_ASYNC 4
|
||||
|
||||
/* Hard limit on the notices stored by the Python connection */
|
||||
#define CONN_NOTICES_LIMIT 50
|
||||
|
||||
extern PyTypeObject connectionType;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -45,8 +45,13 @@ conn_notice_callback(void *args, const char *message)
|
|||
|
||||
if (self->protocol < 3 && strncmp(message, "ERROR", 5) == 0)
|
||||
pq_set_critical(self, message);
|
||||
else
|
||||
else {
|
||||
PyList_Append(self->notice_list, PyString_FromString(message));
|
||||
|
||||
/* Remove the oldest item if the queue is getting too long. */
|
||||
if (PyList_GET_SIZE(self->notice_list) > CONN_NOTICES_LIMIT)
|
||||
PySequence_DelItem(self->notice_list, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* conn_connect - execute a connection to the dataabase */
|
||||
|
|
Loading…
Reference in New Issue
Block a user