[pypy-issue] Issue #2595: [Stackless] Killing tasklet blocked on a channel (pypy/pypy)
Wojciech Kordalski
issues-reply at bitbucket.org
Sun Jun 25 17:49:21 EDT 2017
New issue 2595: [Stackless] Killing tasklet blocked on a channel
https://bitbucket.org/pypy/pypy/issues/2595/stackless-killing-tasklet-blocked-on-a
Wojciech Kordalski:
Reproduction:
1. Kill tasklet blocked on receiving from a channel
2. Send message to the channel
Actual result: channel tries to resume killed tasklet
Expected result (one of the two):
* when tasklet blocked on a channel is killed, it removes itself from the channel's queue
* during send operation on the channel killed tasklets are ignored
Example code:
```py
from stackless import tasklet, channel, getcurrent, run, schedule
c = channel()
def sender():
print("Sending 1 by {}".format(getcurrent()))
c.send(1)
def receiver():
v = c.receive()
print("Received {} by {}".format(v, getcurrent()))
def killer(tl):
print("Killing {} by {}".format(tl, getcurrent()))
tl.kill()
def main():
trk = tasklet(receiver)()
print("Receiver tasklet: {}".format(trk))
schedule()
print("Channel: {}".format(c))
killer(trk)
schedule()
print("Channel: {}".format(c))
tasklet(sender)()
schedule()
tasklet(receiver)()
schedule()
tasklet(main)()
run()
```
Current output:
```
Receiver tasklet: <tasklet[, 2]>
Channel: channel[](-1,deque([<tasklet[, 2]>]))
Killing <tasklet[, 2]> by <tasklet[, 1]>
Channel: channel[](-1,deque([<tasklet[, 2]>]))
Sending 1 by <tasklet[, 3]>
Traceback (most recent call last):
File "bug.py", line 37, in <module>
run()
File "/opt/pypy3/lib_pypy/stackless.py", line 484, in run
schedule()
File "/opt/pypy3/lib_pypy/stackless.py", line 524, in schedule
_scheduler_switch(curr, task)
File "/opt/pypy3/lib_pypy/stackless.py", line 150, in _scheduler_switch
next.switch()
File "/opt/pypy3/lib_pypy/stackless.py", line 65, in switch
current._frame.switch(to=self._frame)
File "/opt/pypy3/lib_pypy/stackless.py", line 53, in run
return func(*argl, **argd)
File "/opt/pypy3/lib_pypy/stackless.py", line 415, in _func
func(*argl, **argd)
File "bug.py", line 8, in sender
c.send(1)
File "/opt/pypy3/lib_pypy/stackless.py", line 340, in send
return self._channel_action(msg, 1)
File "/opt/pypy3/lib_pypy/stackless.py", line 307, in _channel_action
schedule()
File "/opt/pypy3/lib_pypy/stackless.py", line 524, in schedule
_scheduler_switch(curr, task)
File "/opt/pypy3/lib_pypy/stackless.py", line 150, in _scheduler_switch
next.switch()
File "/opt/pypy3/lib_pypy/stackless.py", line 65, in switch
current._frame.switch(to=self._frame)
_continuation.error: continulet already finished
```
More information about the pypy-issue
mailing list