File tree Expand file tree Collapse file tree 1 file changed +5
-11
lines changed Expand file tree Collapse file tree 1 file changed +5
-11
lines changed Original file line number Diff line number Diff 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 :
You can’t perform that action at this time.
0 commit comments