Skip to content

Commit 2f196b2

Browse files
committed
Consolidate logic
1 parent a53ed90 commit 2f196b2

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

newrelic/core/trace_cache.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def current_thread_id(self):
111111
112112
"""
113113

114-
if self.greenlet:
114+
if self.greenlet and self._cache.data:
115115
# Greenlet objects are maintained in a tree structure with
116116
# the 'parent' attribute pointing to that which a specific
117117
# instance is associated with. Only the root node has no
@@ -128,10 +128,9 @@ def current_thread_id(self):
128128
# Unfortunately, instead of returning None, this will segfault
129129
# if attempting to access a non-existent greenlet object.
130130
# https://github.com/python-greenlet/greenlet/blob/master/src/greenlet/TThreadStateCreator.hpp#L57
131-
if self._cache.data:
132-
current = self.greenlet.getcurrent()
133-
if current is not None and current.parent:
134-
return id(current)
131+
current = self.greenlet.getcurrent()
132+
if current is not None and current.parent:
133+
return id(current)
135134

136135
if self.asyncio:
137136
task = current_task(self.asyncio)

0 commit comments

Comments
 (0)