On Saturday, 25 February 2017 14:56:53 GMT Ralph Corderoy wrote:
> Although your code now has two threads, your first initial main one, and
> the one GPIO creates once you start wanting it to watch for interrupt
> events, there's still Python's GIL, Global Interpreter Lock, and the
> second thread's C code has to aquire it before it can run the Python
> code of your callback function, and then release it.  Once released,
> Python code in your main thread, that was held up waiting for the lock,
> will continue.
> 
> Does that explain the `isn't busy' behaviour?

Yes.  And I kind of understood that.  I have read about the GIL without 
necessarily understanding it other than that it limits how many threads Python 
can manage at once.

It's one reason why I thought multiprocessing might be needed, because I 
understand that this gets over the problem with the GIL.
 
> Your callbacks will need a `gpio' or `channel' parameter else I'd expect
> an error when GPIO tries to call them.

I never tried it without one; if I copy code then I don't change anything that 
doesn't look as if it needs changing :-)

-- 



                Terry Coles

-- 
Next meeting:  Bournemouth, Tuesday, 2017-03-07 20:00
Meets, Mailing list, IRC, LinkedIn, ...  http://dorset.lug.org.uk/
New thread:  mailto:dorset@mailman.lug.org.uk / CHECK IF YOU'RE REPLYING
Reporting bugs well:  http://goo.gl/4Xue     / TO THE LIST OR THE AUTHOR

Reply via email to