fix some awkward crashes around killing tasklets
This commit is contained in:
parent
04963f4512
commit
59f0fc890a
|
@ -1,4 +1,5 @@
|
||||||
import stackless
|
import stackless
|
||||||
|
import greenlet
|
||||||
import random
|
import random
|
||||||
import logging
|
import logging
|
||||||
import pickle
|
import pickle
|
||||||
|
@ -85,7 +86,7 @@ class Oob(object):
|
||||||
self.ev.rgtk.append(self.tok)
|
self.ev.rgtk.append(self.tok)
|
||||||
self.tok.mpevDgoob[self.ev] = self.dgoob
|
self.tok.mpevDgoob[self.ev] = self.dgoob
|
||||||
def __exit__(self, etype, eval, tb):
|
def __exit__(self, etype, eval, tb):
|
||||||
if etype != TaskletExit:
|
if etype != greenlet.GreenletExit:
|
||||||
try:
|
try:
|
||||||
self.tok.mpevDgoob.pop(self.ev)
|
self.tok.mpevDgoob.pop(self.ev)
|
||||||
self.ev.rgtk.remove(self.tok)
|
self.ev.rgtk.remove(self.tok)
|
||||||
|
@ -529,7 +530,7 @@ class Token(Taggable):
|
||||||
def runI(self):
|
def runI(self):
|
||||||
try:
|
try:
|
||||||
self.run()
|
self.run()
|
||||||
#except TaskletExit:
|
#except greenlet.GreenletExit:
|
||||||
# raise
|
# raise
|
||||||
except Exception:
|
except Exception:
|
||||||
print "token script crashed:"
|
print "token script crashed:"
|
||||||
|
|
|
@ -14,13 +14,15 @@ class Scheduler(object):
|
||||||
self.rgtasklet.append(tasklet)
|
self.rgtasklet.append(tasklet)
|
||||||
|
|
||||||
def kill(self, tasklet):
|
def kill(self, tasklet):
|
||||||
if not tasklet.g.dead:
|
|
||||||
tasklet.g.parent = greenlet.getcurrent()
|
|
||||||
tasklet.g.throw()
|
|
||||||
try:
|
try:
|
||||||
self.rgtasklet.remove(tasklet)
|
self.rgtasklet.remove(tasklet)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
if tasklet.g == greenlet.getcurrent():
|
||||||
|
raise greenlet.GreenletExit()
|
||||||
|
elif not tasklet.g.dead:
|
||||||
|
tasklet.g.parent = greenlet.getcurrent()
|
||||||
|
tasklet.g.throw()
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.g = greenlet.getcurrent()
|
self.g = greenlet.getcurrent()
|
||||||
|
|
Loading…
Reference in a new issue