From 1c8281f4280fd7e41d0518404b7cb757b2bed345 Mon Sep 17 00:00:00 2001 From: Ondrej Mikle Date: Sun, 29 Oct 2017 16:34:41 +0100 Subject: [PATCH] Fix GIL when waiting for tag --- brmdoor_nfc.config.sample | 2 +- nfc_smartcard.cpp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/brmdoor_nfc.config.sample b/brmdoor_nfc.config.sample index 7eef831..b2bdfb6 100644 --- a/brmdoor_nfc.config.sample +++ b/brmdoor_nfc.config.sample @@ -46,7 +46,7 @@ reconnect_delay = 300 # Controls showing status of "OPEN/CLOSE" switch that is connected to some GPIO pin # Changes topic of connected IRC channels if IRC is enabled # There is no point in enabling this if you disabled IRC -# Not yet usable - do not use because of GIL and python-irc not retrieving topic from channel +# Still has one bug - python-irc won't retrieve properly topic # enabled - True/False # status_file - file in sysfs that contains 1 or 0 defining the state of button # open_value - which value in status_file respresents the switch being in "OPEN" position, 1 character diff --git a/nfc_smartcard.cpp b/nfc_smartcard.cpp index ad37b81..89ac373 100644 --- a/nfc_smartcard.cpp +++ b/nfc_smartcard.cpp @@ -2,6 +2,8 @@ #include #include +#include + #include #include #include @@ -102,7 +104,10 @@ std::string NFCDevice::scanUID() throw(NFCError) throw NFCError("NFC device not opened"); } + Py_BEGIN_ALLOW_THREADS res = nfc_initiator_poll_target(_nfcDevice, _modulations, _modulationsLen, pollNr, pollPeriod, &nt); + Py_END_ALLOW_THREADS + if (res < 0) { throw NFCError("NFC polling error"); }