Threading identifier was not given a unique name. So, a name will be
passed to force it. This behaviour is described at threading docs:
https://docs.python.org/2/library/threading.html#threading.Thread.ident
Thread identifiers may be recycled when a thread exits and another
thread is created. The identifier is available even after the thread has
exited.
Signed-off-by: Ramon Medeiros <ramonn(a)linux.vnet.ibm.com>
---
Changes:
v2:
More verbose commit message
src/wok/objectstore.py | 4 ++--
tests/test_objectstore.py | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/wok/objectstore.py b/src/wok/objectstore.py
index 817f60c..a571e5f 100644
--- a/src/wok/objectstore.py
+++ b/src/wok/objectstore.py
@@ -1,6 +1,6 @@
# Project Wok
#
-# Copyright IBM Corp, 2015-2016
+# Copyright IBM Corp, 2015-2017
#
# Code derived from Project Kimchi
#
@@ -115,7 +115,7 @@ class ObjectStore(object):
return
def _get_conn(self):
- ident = threading.currentThread().ident
+ ident = threading.currentThread().name
try:
return self._connections[ident]
except KeyError:
diff --git a/tests/test_objectstore.py b/tests/test_objectstore.py
index 3ea7b70..96bcf13 100644
--- a/tests/test_objectstore.py
+++ b/tests/test_objectstore.py
@@ -2,7 +2,7 @@
#
# Project Wok
#
-# Copyright IBM Corp, 2015-2016
+# Copyright IBM Corp, 2015-2017
#
# Code delivered from Project Kimchi
#
@@ -91,7 +91,7 @@ class ObjectStoreTests(unittest.TestCase):
threads = []
for i in xrange(50):
- t = threading.Thread(target=worker, args=(i,))
+ t = threading.Thread(target=worker, args=(i,), name=str(i))
t.setDaemon(True)
t.start()
threads.append(t)
--
2.7.4