标签: python-2.7 concurrency gevent
在池中运行gevents时,是否有办法识别池中哪个线程在给定时间运行?这对于记录非常有用。
例如:
from gevent.pool import Pool def func(arg): pool_id = #some way to id the pool logger.debug("[{}] {}".format(pool_id, arg)) pool = Pool(10): pool.map(func, range(50))
答案 0 :(得分:0)
threading.current_thread()
或
threading.get_ident() for python> = 3.3。