From 009c8fa7be02f9a986e5cf078ce40e1188738c89 Mon Sep 17 00:00:00 2001 From: David Wagner Date: Thu, 23 Apr 2015 17:44:31 +0200 Subject: python bindings: activate thread-safety code generation The Parameter Framework may spawn a thread listening to request for command execution. In this case, whenever a command produces a log, a callback function provided by the client is called. When the client is a python script using the python bindings, this causes a python function to be called in a different context than the main thread. This can only work safely if a specific lock is held before hand; see https://docs.python.org/2/c-api/init.html#non-python-created-threads Fortunately, SWIG can generate the corresponding code automatically using %module(threads=1, ...) mymodule Signed-off-by: David Wagner --- bindings/python/pfw.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindings/python/pfw.i b/bindings/python/pfw.i index 9dbccbd..2d39228 100644 --- a/bindings/python/pfw.i +++ b/bindings/python/pfw.i @@ -32,7 +32,7 @@ // like derived C++ classes (calls to virtual methods will be properly // forwarded to Python) - only on classes for which is it specified, see // ILogger below.. -%module(directors="1") PyPfw +%module(directors="1", threads="1") PyPfw %feature("director:except") { if ($error != NULL) { -- cgit v1.1