mirror of https://git.kore.io/kore.git
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;
|
struct connection *c;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static PyObject *pyconnection_disconnect(struct pyconnection *, PyObject *);
|
||||||
|
|
||||||
static PyMethodDef pyconnection_methods[] = {
|
static PyMethodDef pyconnection_methods[] = {
|
||||||
|
METHOD("disconnect", pyconnection_disconnect, METH_NOARGS),
|
||||||
METHOD(NULL, NULL, -1),
|
METHOD(NULL, NULL, -1),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static PyObject *pyconnection_get_fd(struct pyconnection *, void *);
|
||||||
|
|
||||||
static PyGetSetDef pyconnection_getset[] = {
|
static PyGetSetDef pyconnection_getset[] = {
|
||||||
|
GETTER("fd", pyconnection_get_fd),
|
||||||
GETTER(NULL, NULL),
|
GETTER(NULL, NULL),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
19
src/python.c
19
src/python.c
|
@ -667,6 +667,25 @@ pyconnection_alloc(struct connection *c)
|
||||||
return ((PyObject *)pyc);
|
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 *
|
static PyObject *
|
||||||
pyhttp_request_alloc(struct http_request *req)
|
pyhttp_request_alloc(struct http_request *req)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue