commit:     10253819aae4cefee80f377e167ad521516d66a2
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu May  3 01:18:39 2018 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu May  3 01:18:39 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=10253819

WriterPipeClosedTestCase: add_writer after pipe is filled

Hopefully this supresses a spurious writer callback observed
once for pypy in travis.

See: https://travis-ci.org/gentoo/portage/jobs/373734825

 pym/portage/tests/util/futures/asyncio/test_pipe_closed.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/pym/portage/tests/util/futures/asyncio/test_pipe_closed.py 
b/pym/portage/tests/util/futures/asyncio/test_pipe_closed.py
index 1ecddab78..5398ca35c 100644
--- a/pym/portage/tests/util/futures/asyncio/test_pipe_closed.py
+++ b/pym/portage/tests/util/futures/asyncio/test_pipe_closed.py
@@ -105,7 +105,6 @@ class WriterPipeClosedTestCase(_PipeClosedTestCase, 
TestCase):
 
                        writer_callback.called = loop.create_future()
                        _set_nonblocking(write_end.fileno())
-                       loop.add_writer(write_end.fileno(), writer_callback)
 
                        # Fill up the pipe, so that no writer callbacks should 
be
                        # received until the state has changed.
@@ -117,6 +116,11 @@ class WriterPipeClosedTestCase(_PipeClosedTestCase, 
TestCase):
                                                raise
                                        break
 
+                       # We've seen at least one spurious writer callback when
+                       # this was registered before the pipe was filled, so
+                       # register it afterwards.
+                       loop.add_writer(write_end.fileno(), writer_callback)
+
                        # Allow the loop to check for IO events, and assert
                        # that our future is still not done.
                        loop.run_until_complete(asyncio.sleep(0, loop=loop))

Reply via email to