ret->source = NULL;
+ Py_BEGIN_ALLOW_THREADS;
rv = gpiod_line_event_read(self->line, &ret->event);
+ Py_END_ALLOW_THREADS;
if (rv) {
PyErr_SetFromErrno(PyExc_OSError);
Py_DECREF(ret);
}
}
+ Py_BEGIN_ALLOW_THREADS;
rv = gpiod_line_request_bulk(&bulk, &conf, default_vals);
+ Py_END_ALLOW_THREADS;
if (rv) {
PyErr_SetFromErrno(PyExc_OSError);
return NULL;
gpiod_LineBulkObjToCLineBulk(self, &bulk);
memset(vals, 0, sizeof(vals));
+ Py_BEGIN_ALLOW_THREADS;
rv = gpiod_line_get_value_bulk(&bulk, vals);
+ Py_END_ALLOW_THREADS;
if (rv) {
PyErr_SetFromErrno(PyExc_OSError);
return NULL;
vals[i] = (int)val;
}
+ Py_BEGIN_ALLOW_THREADS;
rv = gpiod_line_set_value_bulk(&bulk, vals);
+ Py_END_ALLOW_THREADS;
if (rv) {
PyErr_SetFromErrno(PyExc_OSError);
return NULL;
gpiod_LineBulkObjToCLineBulk(self, &bulk);
+ Py_BEGIN_ALLOW_THREADS;
rv = gpiod_line_event_wait_bulk(&bulk, &ts, &ev_bulk);
+ Py_END_ALLOW_THREADS;
if (rv < 0) {
PyErr_SetFromErrno(PyExc_OSError);
return NULL;
static int gpiod_Chip_init(gpiod_ChipObject *self, PyObject *args)
{
int rv, how = gpiod_OPEN_LOOKUP;
+ PyThreadState *thread;
char *descr;
rv = PyArg_ParseTuple(args, "s|i", &descr, &how);
if (!rv)
return -1;
+ thread = PyEval_SaveThread();
switch (how) {
case gpiod_OPEN_LOOKUP:
self->chip = gpiod_chip_open_lookup(descr);
self->chip = gpiod_chip_open_by_number(atoi(descr));
break;
default:
+ PyEval_RestoreThread(thread);
PyErr_BadArgument();
return -1;
}
+ PyEval_RestoreThread(thread);
if (!self->chip) {
PyErr_SetFromErrno(PyExc_OSError);
return -1;
if (!rv)
return NULL;
+ Py_BEGIN_ALLOW_THREADS;
line = gpiod_chip_get_line(self->chip, offset);
+ Py_END_ALLOW_THREADS;
if (!line) {
PyErr_SetFromErrno(PyExc_OSError);
return NULL;
if (!rv)
return NULL;
+ Py_BEGIN_ALLOW_THREADS;
line = gpiod_chip_find_line(self->chip, name);
+ Py_END_ALLOW_THREADS;
if (!line) {
PyErr_SetFromErrno(PyExc_OSError);
return NULL;
gpiod_ChipObject *chip_obj;
struct gpiod_chip *chip;
+ Py_BEGIN_ALLOW_THREADS;
chip = gpiod_chip_iter_next_noclose(self->iter);
+ Py_END_ALLOW_THREADS;
if (!chip)
return NULL; /* Last element. */
if (!rv)
return -1;
+ Py_BEGIN_ALLOW_THREADS;
self->iter = gpiod_line_iter_new(chip_obj->chip);
+ Py_END_ALLOW_THREADS;
if (!self->iter) {
PyErr_SetFromErrno(PyExc_OSError);
return -1;
if (!rv)
return NULL;
+ Py_BEGIN_ALLOW_THREADS;
line = gpiod_line_find(name);
+ Py_END_ALLOW_THREADS;
if (!line) {
PyErr_SetFromErrno(PyExc_OSError);
return NULL;