mirror of
https://github.com/jorisvink/kore
synced 2025-03-09 20:49:01 -04:00
expose c.disconnect() and c.fd to Python.
This commit is contained in:
parent
af899f15e0
commit
0b84a9c1d4
@ -51,11 +51,17 @@ struct pyconnection {
|
||||
struct connection *c;
|
||||
};
|
||||
|
||||
static PyObject *pyconnection_disconnect(struct pyconnection *, PyObject *);
|
||||
|
||||
static PyMethodDef pyconnection_methods[] = {
|
||||
METHOD("disconnect", pyconnection_disconnect, METH_NOARGS),
|
||||
METHOD(NULL, NULL, -1),
|
||||
};
|
||||
|
||||
static PyObject *pyconnection_get_fd(struct pyconnection *, void *);
|
||||
|
||||
static PyGetSetDef pyconnection_getset[] = {
|
||||
GETTER("fd", pyconnection_get_fd),
|
||||
GETTER(NULL, NULL),
|
||||
};
|
||||
|
||||
|
19
src/python.c
19
src/python.c
@ -667,6 +667,25 @@ pyconnection_alloc(struct connection *c)
|
||||
return ((PyObject *)pyc);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
pyconnection_disconnect(struct pyconnection *pyc, PyObject *args)
|
||||
{
|
||||
kore_connection_disconnect(pyc->c);
|
||||
|
||||
Py_RETURN_TRUE;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
pyconnection_get_fd(struct pyconnection *pyc, void *closure)
|
||||
{
|
||||
PyObject *fd;
|
||||
|
||||
if ((fd = PyLong_FromLong(pyc->c->fd)) == NULL)
|
||||
return (PyErr_NoMemory());
|
||||
|
||||
return (fd);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
pyhttp_request_alloc(struct http_request *req)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user