Skip to content

Commit a53ed90

Browse files
committed
Add comment
1 parent 7695b1a commit a53ed90

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

newrelic/core/trace_cache.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -122,21 +122,15 @@ def current_thread_id(self):
122122
# all other cases where we can obtain a current greenlet,
123123
# then it should indicate we are running as a greenlet.
124124

125-
# current = self.greenlet.getcurrent()
126-
# if current is not None and current.parent:
127-
# return id(current)
128-
129125
# In this case, the garbage collector could have already
130-
# collected the greenlet object, so we need to check if the
131-
# weakref is still alive before we can access the parent
132-
133-
# print(f"cache: {self._cache.data}")
134-
# print(f"thread id: {thread.get_ident()}")
126+
# collected the final greenlet object, so we need to check if
127+
# the weakref is still alive before we can access the parent.
128+
# Unfortunately, instead of returning None, this will segfault
129+
# if attempting to access a non-existent greenlet object.
130+
# https://github.com/python-greenlet/greenlet/blob/master/src/greenlet/TThreadStateCreator.hpp#L57
135131
if self._cache.data:
136132
current = self.greenlet.getcurrent()
137-
# print(f"greenlet id: {id(current)}")
138133
if current is not None and current.parent:
139-
# print(f"greenlet id with parent: {id(current)}")
140134
return id(current)
141135

142136
if self.asyncio:

0 commit comments

Comments
 (0)