On this page
threading.get_ident
Prev: threading.ExceptHookArgs | Up: threading | Next: threading.get_native_id
Rel: threading.active_count, threading.Barrier, threading.BoundedSemaphore, threading.BrokenBarrierError
Ref: docs.python.org — threading.get_ident
Tags: #public #python3 #stdlib #threading
Import
import threading
from threading import get_ident
Signature & Overview
threading.get_ident()
Return a non-zero integer that uniquely identifies the current thread amongst other threads that exist simultaneously.
Usage
import threading
ident = threading.get_ident()
assert isinstance(ident, int) and ident != 0
Gotchas
- IDs may be recycled after a thread exits: Use
get_ident()only for currently alive threads (for OS-level thread IDs matchingtop/debuggers, useget_native_id()).
REPL Inspect
from threading import get_ident
help(get_ident)
Linked from
Related notes
- tuts/python3/stdlib_module/threading/ExceptHookArgs Linked here; links to this page; shared tags: #stdlib, #threading
- tuts/python3/stdlib_module/threading/get_native_id Linked here; links to this page; shared tags: #stdlib, #threading
- tuts/python3/stdlib_module/threading Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/threading/active_count Linked here; shared tags: #stdlib, #threading
- tuts/python3/stdlib_module/threading/Barrier Linked here; shared tags: #stdlib, #threading
- tuts/python3/stdlib_module/threading/BoundedSemaphore Linked here; shared tags: #stdlib, #threading
- tuts/python3/stdlib_module/threading/BrokenBarrierError Linked here; shared tags: #stdlib, #threading
- tuts/python3/stdlib_module/threading/Condition shared tags: #stdlib, #threading
- tuts/python3/stdlib_module/threading/current_thread shared tags: #stdlib, #threading
- tuts/python3/stdlib_module/threading/enumerate shared tags: #stdlib, #threading