Avital
Avital

Reputation: 81

Thread id in tornado-Python

I am using 'run_on_executor' tornado decorator and would like to detect the current thread id. i know that in python it is possible to get the thread id by 'get_ident' function, but how can i use it if i am using 'run_on_executor'?

from tornado.concurrent import run_on_executor
from concurrent.futures import ThreadPoolExecutor
...
class SampleThreaded(object):
    executor = ThreadPoolExecutor(4)
    @run_on_executor
    def func1(self):
        thread_id = ???

Upvotes: 0

Views: 452

Answers (1)

donkopotamus
donkopotamus

Reputation: 23186

In this case you can still find the thread id using thread.get_ident(), or threading.current_thread().ident.

Upvotes: 1

Related Questions