filter/python3: support multi-threaded python custon filters.
authorMyungJoo Ham <myungjoo.ham@samsung.com>
Thu, 7 Jul 2022 08:04:49 +0000 (17:04 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Mon, 11 Jul 2022 08:13:27 +0000 (17:13 +0900)
commit0d454fde9b70955c509c0af399a8c69085e91469
treef35a656e5bee47567d1aecd4d8aba94b29d6e503
parent33f4264bdc922fe3df568ccaecaf25143731c4bc
filter/python3: support multi-threaded python custon filters.

Use Python GIL for multi-threaded python custom filters.
Don't use a local lock, use GIL.

Fixes #3822

Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
ps. The execution result of CV2 enabled python code of #3822:

```
$ gst-launch-1.0 videotestsrc num-buffers=10 ! video/x-raw,format=RGB,width=280,height=40 ! tensor_converter ! tensor_filter framework=python3 model=p2.py input=3:280:40:1 inputtype=uint8 output=3:280:40:1 outputtype=uint8  ! tensor_decoder mode=direct_video ! videoconvert ! ximagesink
init_filter_py:844
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
--- USE_CV2:True /source/AutoDrv/NNStreamer/tests/p2.py (33600,)
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
--- USE_CV2:True /source/AutoDrv/NNStreamer/tests/p2.py (33600,)
--- USE_CV2:True /source/AutoDrv/NNStreamer/tests/p2.py (33600,)
--- USE_CV2:True /source/AutoDrv/NNStreamer/tests/p2.py (33600,)
--- USE_CV2:True /source/AutoDrv/NNStreamer/tests/p2.py (33600,)
--- USE_CV2:True /source/AutoDrv/NNStreamer/tests/p2.py (33600,)
--- USE_CV2:True /source/AutoDrv/NNStreamer/tests/p2.py (33600,)
--- USE_CV2:True /source/AutoDrv/NNStreamer/tests/p2.py (33600,)
--- USE_CV2:True /source/AutoDrv/NNStreamer/tests/p2.py (33600,)
--- USE_CV2:True /source/AutoDrv/NNStreamer/tests/p2.py (33600,)
Got EOS from element "pipeline0".
Execution ended after 0:00:00.333332913
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...
```
ext/nnstreamer/extra/nnstreamer_python3_helper.h
ext/nnstreamer/tensor_filter/tensor_filter_python3.cc