Added monitor to avoid more than one thread to use python GIL at the same time