switch to using ctypes in echopy
move semaphore from C++ to Python