Note: the difference from get_current_thread_id to get_thread_id is that for the current thread we can get the thread id while the thread.ident is still not set in the Thread instance.
(thread)
| 647 | |
| 648 | |
| 649 | def get_current_thread_id(thread): |
| 650 | """ |
| 651 | Note: the difference from get_current_thread_id to get_thread_id is that |
| 652 | for the current thread we can get the thread id while the thread.ident |
| 653 | is still not set in the Thread instance. |
| 654 | """ |
| 655 | try: |
| 656 | # Fast path without getting lock. |
| 657 | tid = thread.__pydevd_id__ |
| 658 | if tid is None: |
| 659 | # Fix for https://www.brainwy.com/tracker/PyDev/645 |
| 660 | # if __pydevd_id__ is None, recalculate it... also, use an heuristic |
| 661 | # that gives us always the same id for the thread (using thread.ident or id(thread)). |
| 662 | raise AttributeError() |
| 663 | except AttributeError: |
| 664 | tid = _get_or_compute_thread_id_with_lock(thread, is_current_thread=True) |
| 665 | |
| 666 | return tid |
| 667 | |
| 668 | |
| 669 | def get_thread_id(thread): |