@@ -400,7 +400,9 @@ SpiDev_xfer2(SpiDevObject *self, PyObject *args)
400
400
PyObject * obj ;
401
401
PyObject * seq ;
402
402
struct spi_ioc_transfer xfer ;
403
+ Py_BEGIN_ALLOW_THREADS
403
404
memset (& xfer , 0 , sizeof (xfer ));
405
+ Py_END_ALLOW_THREADS
404
406
uint8_t * txbuf , * rxbuf ;
405
407
char wrmsg_text [4096 ];
406
408
@@ -420,8 +422,10 @@ SpiDev_xfer2(SpiDevObject *self, PyObject *args)
420
422
return NULL ;
421
423
}
422
424
425
+ Py_BEGIN_ALLOW_THREADS
423
426
txbuf = malloc (sizeof (__u8 ) * len );
424
427
rxbuf = malloc (sizeof (__u8 ) * len );
428
+ Py_END_ALLOW_THREADS
425
429
426
430
for (ii = 0 ; ii < len ; ii ++ ) {
427
431
PyObject * val = PySequence_Fast_GET_ITEM (seq , ii );
@@ -448,6 +452,7 @@ SpiDev_xfer2(SpiDevObject *self, PyObject *args)
448
452
seq = PySequence_List (obj );
449
453
}
450
454
455
+ Py_BEGIN_ALLOW_THREADS
451
456
xfer .tx_buf = (unsigned long )txbuf ;
452
457
xfer .rx_buf = (unsigned long )rxbuf ;
453
458
xfer .len = len ;
@@ -456,6 +461,7 @@ SpiDev_xfer2(SpiDevObject *self, PyObject *args)
456
461
xfer .bits_per_word = bits_per_word ? bits_per_word : self -> bits_per_word ;
457
462
458
463
status = ioctl (self -> fd , SPI_IOC_MESSAGE (1 ), & xfer );
464
+ Py_END_ALLOW_THREADS
459
465
if (status < 0 ) {
460
466
PyErr_SetFromErrno (PyExc_IOError );
461
467
free (txbuf );
@@ -474,8 +480,10 @@ SpiDev_xfer2(SpiDevObject *self, PyObject *args)
474
480
// Stop generating an extra CS except in mode CS_HOGH
475
481
if (self -> mode & SPI_CS_HIGH ) status = read (self -> fd , & rxbuf [0 ], 0 );
476
482
483
+ Py_BEGIN_ALLOW_THREADS
477
484
free (txbuf );
478
485
free (rxbuf );
486
+ Py_END_ALLOW_THREADS
479
487
480
488
481
489
if (PyTuple_Check (obj )) {
0 commit comments