python threaded 进程ID与线程ID

创建日期: 2022-07-25 11:09 | 作者: 风波 | 浏览次数: 15 | 分类: Python

获取进程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)
15 浏览
10 爬虫
0 评论