Author: Antonio Cuni <[email protected]>
Branch:
Changeset: r94427:05d4bb2624e8
Date: 2018-04-23 15:52 +0200
http://bitbucket.org/pypy/pypy/changeset/05d4bb2624e8/
Log: add a test for 321aff47be74
diff --git a/pypy/interpreter/test/test_executioncontext.py
b/pypy/interpreter/test/test_executioncontext.py
--- a/pypy/interpreter/test/test_executioncontext.py
+++ b/pypy/interpreter/test/test_executioncontext.py
@@ -67,6 +67,47 @@
""")
assert events == ['one']
+ def test_fire_inside_perform(self):
+ # test what happens if we call AsyncAction.fire() while we are in the
+ # middle of an AsyncAction.perform(). In particular, this happens when
+ # PyObjectDeallocAction.fire() is called by rawrefcount: see issue
+ # 2805
+ events = []
+
+ class Action1(executioncontext.AsyncAction):
+ _count = 0
+
+ def perform(self, ec, frame):
+ events.append('one')
+ if self._count == 0:
+ # a1 is no longer in the queue, so it will be enqueued
+ a1.fire()
+ #
+ # a2 is still in the queue, so the fire() is ignored and
+ # it's performed in its normal order, i.e. BEFORE a3
+ a2.fire()
+ self._count += 1
+
+ class Action2(executioncontext.AsyncAction):
+ def perform(self, ec, frame):
+ events.append('two')
+
+ class Action3(executioncontext.AsyncAction):
+ def perform(self, ec, frame):
+ events.append('three')
+
+ space = self.space
+ a1 = Action1(space)
+ a2 = Action2(space)
+ a3 = Action3(space)
+ a1.fire()
+ a2.fire()
+ a3.fire()
+ space.appexec([], """():
+ pass
+ """)
+ assert events == ['one', 'two', 'three', 'one']
+
def test_periodic_action(self):
from pypy.interpreter.executioncontext import ActionFlag
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit