Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling line.event_wait in thread hangs main program #26

Closed
sgjava opened this issue Apr 21, 2018 · 7 comments
Closed

Calling line.event_wait in thread hangs main program #26

sgjava opened this issue Apr 21, 2018 · 7 comments

Comments

@sgjava
Copy link

sgjava commented Apr 21, 2018

Code I have using CFFI/Python 3 and libgpiod 1.0 line.event_wait worked fine in a thread. Using your new Python bindings this code hangs main program until timeout or event fires.

@sgjava sgjava changed the title Calling line.event_wait in thread hangs main thread Calling line.event_wait in thread hangs main program Apr 21, 2018
@brgl
Copy link
Owner

brgl commented Apr 21, 2018

That's interesting, I'm curious if it's not something related to the Global Interpreter Lock in python. I'll take a look.

@brgl
Copy link
Owner

brgl commented Apr 21, 2018

Seems like I will need to use Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW_THREADS before and after the internal call to gpiod_line_event_wait() respectively.

@sgjava
Copy link
Author

sgjava commented Apr 21, 2018

Let me know when you commit changes and I'll test, thanks.

@brgl
Copy link
Owner

brgl commented Apr 21, 2018

@sgjava I don't really have time to test it today, but I pushed a fix to topic/python-locking branch that should theoretically fix it. I should probably add these macros around all blocking operations in the module. Let me know if you can test it and if it works.

@sgjava
Copy link
Author

sgjava commented Apr 21, 2018

I just tested event_wait and it works as expected in a thread. Let me know when you commit changes to master. I'll finish up converting the rest of my example code to the new bindings.

@brgl
Copy link
Owner

brgl commented Apr 22, 2018

Done.

@brgl brgl closed this as completed Apr 22, 2018
@sgjava
Copy link
Author

sgjava commented Apr 23, 2018

I just built and tested my threading example. Looks good, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants