Home - Summaries: (main) : (py3.11) : (py3.12) : Everything - Nightly builds - Benchmarks - RPython - Builders - About

pypy/module/_io/test/apptest_textio.py::test_concurrent_next_at_eof

tempfile = W_UnicodeObject('/private/tmp/buildbot-arm64/pytest/pytest-of-matti/pytest-133/tempfile')

    def test_concurrent_next_at_eof(tempfile):
        # https://github.com/pypy/pypy/issues/5575
        # Two threads iterating the same TextIOWrapper over a real fd can race
        # inside the decode buffer when the underlying read() releases the GIL,
        # especially right at EOF where DecodeBuffer.reset() nulls out its state.
        import _thread
        import time
    
        with _io.open(tempfile, 'wb') as w:
            w.write(b"line\n")
        f = _io.TextIOWrapper(_io.BufferedReader(_io.FileIO(tempfile, "r")))
        it = iter(f)
    
        done = []
    
        def worker():
            for _ in range(10):
                try:
                    next(it)
                except Exception:
                    pass
            done.append(1)
    
        _thread.start_new_thread(worker, ())
        _thread.start_new_thread(worker, ())
        deadline = time.time() + 15.0
        while len(done) < 2:
>           assert time.time() < deadline, "worker threads hung (see issue 5575)"
E           (application-level) AssertionError: worker threads hung (see issue 5575)
E           assert 1789010817.380661 < 1789010816.525941
E            +  where 1789010817.380661 = <built-in function time>()
E            +    where <built-in function time> = <module 'time' (built-in)>.time

module/_io/test/apptest_textio.py:852: AssertionError
builder: own-macos-arm64 build #1386+
test: pypy/module/_io/test/apptest_textio.py::test_concurrent_next_at_eof