File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -119,14 +119,25 @@ def watch(self, callback):
119119 # This is a Gevent Greenlet (capital G), which inherits from
120120 # greenlet and provides a 'link' method to detect when the
121121 # Greenlet exits.
122- current .link (callback )
123- self ._refs [tid ] = None
122+ from gevent .greenlet import SpawnedLink
123+ sl = SpawnedLink (callback )
124+ current .rawlink (sl )
125+ self ._refs [tid ] = sl
126+ #current.link(callback)
127+ #self._refs[tid] = None
124128 else :
125129 # This is a non-Gevent greenlet (small g), or it's the main
126130 # greenlet.
127131 self ._refs [tid ] = weakref .ref (current , callback )
128132
129-
133+ def unwatch (self ):
134+ """ call unlink if link before """
135+ sl = self ._refs .pop (self .get (), None )
136+ current = greenlet .getcurrent ()
137+ if hasattr (current , 'link' ):
138+ current .unlink (sl )
139+
140+
130141def create_ident (use_greenlets ):
131142 if use_greenlets :
132143 return GreenletIdent ()
You can’t perform that action at this time.
0 commit comments