# Get a thread uuid?

**URL:** <https://forum.inductiveautomation.com/t/get-a-thread-uuid/75374>\
**Category:** Ignition\
**Created:** [June 22, 2023, 4:21am UTC](https://forum.inductiveautomation.com/t/get-a-thread-uuid/75374 "2023-06-22T04:21:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [June 22, 2023, 4:21am UTC](https://forum.inductiveautomation.com/t/get-a-thread-uuid/75374/1 "2023-06-22T04:21:56Z")

</div>

I've got a function call logger which records function calls and their args for testing purposes, but what I would like to attach is also the thread uuid that each function is being called from within so that I can link up multiple function calls from the same thread e.g. in the case a function has nested calls to other functions.

I can get the thread id with:

```auto
import threading
threading.currentThread().ident

```

But this id is just a number that is only unique in the time it's running. After it ends, another thread can then use that same number.  
Is there any way that I can ensure all threads have uuids, and read this?

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [June 22, 2023, 4:30am UTC](https://forum.inductiveautomation.com/t/get-a-thread-uuid/75374/2 "2023-06-22T04:30:58Z")

</div>

I've worked around this for now by setting the name of the thread to a uuid if it's not one already

e.g.

```auto
thread = threading.current_thread()
# set the thread name to a UUID if it isn't already
try:
	uuid.UUID(thread.name)
except ValueError:
	thread.setName(str(uuid.uuid4()))

uuid_ = thread.name

```
