Non-blocking behaviour for python bindings
Status: Beta
Brought to you by:
spadix
As discussed in forum thread: https://sourceforge.net/projects/zbar/forums/forum/664596/topic/4094292
Current python Processor bindings do not support threading.
Another idea is to use intermediate Video API to achieve non-blocking barcode processing in Python, but it seems to be not implemented in current bindings.
A fix for this has been pushed to hg (rev 1c14e19910e9).
I did what testing I could, but do not currently have a camera setup, so it would be great if someone could test with video and report back here. Specifically we need tests for:
* setting the processor active and receiving asynchronous calls from the data_handler (single Python thread)
* ensuring that time consuming processor methods (user_wait, process_one, process_image) do not block other threads
Thanks for reporting this!
zbar threading test
Hello everybody
I know that the discussion is old but I have the same case.
I have tried to use this code with 'wait' mode but the process still blocking other threads!
only if I add time.sleep(2) inside the process_data() then I got 2 sec unblock time for other processes.
do I need to use a specific version of Zbar ?
Thanks, nice work! I updated my test script (attached). There are four modes:
normal mode (just activates processor): zbar_threads_test.py
user wait mode: zbar_threads_test.py wait
process one mode: zbar_threads_test.py one
scan image mode: zbar_threads_test.py image /path/to/image
So far everything looks good - main thread is not stalled and periodically emits alive message. Asynchronous data processing hook is also being called.
Thanks again for the testing. btw- if you can find a way to automate these tests, I'll certainly add them to the test suite...