# Is the Python client thread safe?

**URL:** <https://discuss.aerospike.com/t/is-the-python-client-thread-safe/7842>\
**Category:** Python Client\
**Created:** [September 16, 2020, 3:34pm UTC](https://discuss.aerospike.com/t/is-the-python-client-thread-safe/7842 "2020-09-16T15:34:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cloudrave](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/cloudrave/32/1520_2.png) [@cloudrave](https://discuss.aerospike.com/u/cloudrave)\
**Post date:** [September 16, 2020, 3:34pm UTC](https://discuss.aerospike.com/t/is-the-python-client-thread-safe/7842/1 "2020-09-16T15:34:43Z")

</div>

Does anyone know if the Python client is thread safe? Can multiple threads make requests with the client concurrently?

I see the Java client advertises this feature, but the Python client does not, so I’d like to double check.

Thanks for the help!

---

<div class="post-metadata">

**Author:** ![cloudrave](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/cloudrave/32/1520_2.png) [@cloudrave](https://discuss.aerospike.com/u/cloudrave)\
**Post date:** [September 16, 2020, 4:58pm UTC](https://discuss.aerospike.com/t/is-the-python-client-thread-safe/7842/2 "2020-09-16T16:58:10Z")

</div>

Okay, these two things convinced me that it is thread safe 🙃

1. [Example of using threads](https://github.com/aerospike/aerospike-client-python/blob/e2231d697046f0745daaea6bcec615b506e3fab0/examples/client/multi_thread.py)
2. [The library does call `PyEval_InitThreads()` and kindly proclaims `Makes things "thread-safe"`](https://github.com/aerospike/aerospike-client-python/blob/123c92a5f6537936588162015424e3bf9b6e6c57/src/main/aerospike.c#L99-L100)

---

<div class="post-metadata">

**Author:** ![rbotzer](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/rbotzer/32/2114_2.png) [@rbotzer](https://discuss.aerospike.com/u/rbotzer)\
**Post date:** [September 16, 2020, 5:50pm UTC](https://discuss.aerospike.com/t/is-the-python-client-thread-safe/7842/3 "2020-09-16T17:50:13Z")

</div>

Hi! As far as I know the Python client is. The GIL is grabbed for any sync call and released as soon as possible, in order to be a good citizen in a multithreaded system.

I also know that the Python client is used in production with systems like gevent.

Would be good to get any other input from users of the Python client. If anything is missing, we’ll open a feature request.

---

<div class="post-metadata">

**Author:** ![system](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/system/32/2274_2.png) [@system](https://discuss.aerospike.com/u/system)\
**Post date:** [December 9, 2020, 5:50pm UTC](https://discuss.aerospike.com/t/is-the-python-client-thread-safe/7842/4 "2020-12-09T17:50:18Z")

</div>

Closed on December 9, 2020, 5:50pm UTC

This topic was automatically closed 84 days after the last reply. New replies are no longer allowed.
