Skip to content

Commit 0339411

Browse files
author
A. Jesse Jiryu Davis
committed
Ident refactoring
1 parent 19539f0 commit 0339411

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

pymongo/thread_util.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ def watch(self, callback):
5656
"""
5757
raise NotImplementedError
5858

59+
def watching(self):
60+
"""Is the current thread being watched for death?"""
61+
return self.get() in self._refs
62+
5963

6064
class ThreadIdent(Ident):
6165
class _DummyLock(object):
@@ -99,15 +103,6 @@ def watch(self, callback):
99103
vigil = self._make_vigil()
100104
self._refs[id(vigil)] = weakref.ref(vigil, callback)
101105

102-
def watching(self):
103-
"""Is the current thread being watched for death?"""
104-
tid = self.get()
105-
if tid not in self._refs:
106-
return False
107-
# Check that the weakref is active, if not the thread has died
108-
# This fixes the case where a thread id gets reused
109-
return self._refs[tid]()
110-
111106

112107
class GreenletIdent(Ident):
113108
def get(self):

0 commit comments

Comments
 (0)