mirror of
				https://github.com/psycopg/psycopg2.git
				synced 2025-11-04 09:47:30 +03:00 
			
		
		
		
	Added 'get_wait_callback()' function.
This commit is contained in:
		
							parent
							
								
									a7c41a0388
								
							
						
					
					
						commit
						8ba0f00d21
					
				| 
						 | 
				
			
			@ -61,7 +61,7 @@ from _psycopg import ISQLQuote
 | 
			
		|||
from _psycopg import QueryCanceledError, TransactionRollbackError
 | 
			
		||||
 | 
			
		||||
try:
 | 
			
		||||
    from _psycopg import set_wait_callback
 | 
			
		||||
    from _psycopg import set_wait_callback, get_wait_callback
 | 
			
		||||
except ImportError:
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -56,6 +56,25 @@ psyco_set_wait_callback(PyObject *self, PyObject *obj)
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* Return the currently registered wait callback function.
 | 
			
		||||
 *
 | 
			
		||||
 * The function is exported by the _psycopg module.
 | 
			
		||||
 */
 | 
			
		||||
PyObject *
 | 
			
		||||
psyco_get_wait_callback(PyObject *self, PyObject *obj)
 | 
			
		||||
{
 | 
			
		||||
    PyObject *ret;
 | 
			
		||||
 | 
			
		||||
    ret = wait_callback;
 | 
			
		||||
    if (!ret) {
 | 
			
		||||
        ret = Py_None;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    Py_INCREF(ret);
 | 
			
		||||
    return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* Return nonzero if a wait callback should be called. */
 | 
			
		||||
int
 | 
			
		||||
psyco_green()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -47,8 +47,14 @@ extern "C" {
 | 
			
		|||
"\n" \
 | 
			
		||||
"See `~psycopg2.extras.wait_select()` for an example of a wait callback\n" \
 | 
			
		||||
"implementation.\n"
 | 
			
		||||
 | 
			
		||||
HIDDEN PyObject *psyco_set_wait_callback(PyObject *self, PyObject *obj);
 | 
			
		||||
 | 
			
		||||
#define psyco_get_wait_callback_doc \
 | 
			
		||||
"get_wait_callback() -- Return the currently registered wait callback.\n" \
 | 
			
		||||
"\n" \
 | 
			
		||||
"Return `None` if no callback is currently registered.\n"
 | 
			
		||||
HIDDEN PyObject *psyco_get_wait_callback(PyObject *self, PyObject *obj);
 | 
			
		||||
 | 
			
		||||
HIDDEN int psyco_green(void);
 | 
			
		||||
HIDDEN PyObject *psyco_wait(PyObject *conn, PyObject *curs);
 | 
			
		||||
HIDDEN PGresult *psyco_exec_green(connectionObject *conn, const char *command);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -697,6 +697,8 @@ static PyMethodDef psycopgMethods[] = {
 | 
			
		|||
#ifdef PSYCOPG_EXTENSIONS
 | 
			
		||||
    {"set_wait_callback",  (PyCFunction)psyco_set_wait_callback,
 | 
			
		||||
     METH_O, psyco_set_wait_callback_doc},
 | 
			
		||||
    {"get_wait_callback",  (PyCFunction)psyco_get_wait_callback,
 | 
			
		||||
     METH_NOARGS, psyco_get_wait_callback_doc},
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    {NULL, NULL, 0, NULL}        /* Sentinel */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user