获取进程ID
import os
pid = os.getpid()
获取线程ID
获取线程对象标记:threading.ident
threading 对象的标识 ident,而并非系统线程ID
import threading
tid = threading.currentThread().ident
获取系统的线程ID
import ctypes
SYS_gettid = 186
libc = ctypes.cdll.LoadLibrary('libc.so.6')
tid = libc.syscall(SYS_gettid)