@@ -198,6 +198,7 @@ PyArrayObject* load_npy_script(std::string const& source,
198
198
void NumpyReader::initialize ()
199
199
{
200
200
plang::Environment::get ();
201
+ plang::gil_scoped_acquire acquire;
201
202
m_numPoints = 0 ;
202
203
m_chunkCount = 0 ;
203
204
m_ndims = 0 ;
@@ -424,6 +425,7 @@ void NumpyReader::addDimensions(PointLayoutPtr layout)
424
425
{
425
426
using namespace Dimension ;
426
427
428
+ plang::gil_scoped_acquire acquire;
427
429
wakeUpNumpyArray ();
428
430
createFields (layout);
429
431
@@ -485,6 +487,7 @@ void NumpyReader::addDimensions(PointLayoutPtr layout)
485
487
486
488
void NumpyReader::ready (PointTableRef table)
487
489
{
490
+ plang::gil_scoped_acquire acquire;
488
491
plang::Environment::get ()->set_stdout (log ()->getLogStream ());
489
492
490
493
// Set our iterators
@@ -528,6 +531,8 @@ bool NumpyReader::nextPoint()
528
531
// just advance by the stride.
529
532
if (--m_chunkCount == 0 )
530
533
{
534
+ // Go grab the gil before we touch Python stuff again
535
+ plang::gil_scoped_acquire acquire;
531
536
// If we can't fetch the next ite
532
537
if (!m_iternext (m_iter))
533
538
return false ;
@@ -653,6 +658,7 @@ bool NumpyReader::processOne(PointRef& point)
653
658
654
659
point_count_t NumpyReader::read (PointViewPtr view, point_count_t numToRead)
655
660
{
661
+ plang::gil_scoped_acquire acquire;
656
662
PointId idx = view->size ();
657
663
point_count_t numRead (0 );
658
664
@@ -670,8 +676,8 @@ point_count_t NumpyReader::read(PointViewPtr view, point_count_t numToRead)
670
676
671
677
void NumpyReader::done (PointTableRef)
672
678
{
679
+ plang::gil_scoped_acquire acquire;
673
680
// Dereference everything we're using
674
-
675
681
if (m_iter)
676
682
NpyIter_Deallocate (m_iter);
677
683
0 commit comments