Python interface made threadsafe