On Sep 29, 4:56 pm, Alexandru Mosoi <[EMAIL PROTECTED]> wrote: > how can I block all threads for a specific amount of time? (i need to > sleep whole process for testing purposes). i thought of accessing GIL > and sleep for some amount of time, but I don't know how to do this and > whether GIL is recursive.
You could do this in C by sleeping while holding the GIL: #ifdef WIN32 #include <Windows.h> #define __sleep(ms) Sleep((DWORD)ms) #else #include <unistd.h> #define __sleep(ms) usleep((useconds_t)ms) #endif __declspec(dllexport) void sleep(int ms) { __sleep(ms); } Save this in a file called "gilsleep.c" and compile it as a DLL (gilslepp.dll in Windows, gilsleep.so in Linux). Then in Python: import ctypes sleep = ctypes.pydll.gilsleep.sleep sleep.argtypes = (ctypes.c_int,) sleep.restype = None sleep(500) # blocks all threads for 500 ms -- http://mail.python.org/mailman/listinfo/python-list