Thanks to this post , I got Python threads to report their respective thread IDs. First do grep -r 'SYS_gettid' /usr/include/' . I got the line: #define SYS_gettid __NR_gettid With further grepping on grep -r '__NR_gettid' /usr/include/ I got a bunch of matching lines:
/usr/include/x86_64-linux-gnu/asm/unistd_32.h:#define __NR_gettid 224 /usr/include/x86_64-linux-gnu/asm/unistd_64.h:#define __NR_gettid 186 /usr/include/asm-generic/unistd.h:#define __NR_gettid 178
Now choose the one that fits your architecture. Mine was 186. Now include this code in all your Python stream scripts to get the stream ID, as the OS shows:
import ctypes tid = ctypes.CDLL('libc.so.6').syscall(186)
Phani
source share