mirror of
https://github.com/pybind/pybind11.git
synced 2026-03-14 20:27:47 +00:00
pythonbuf fix (#2675)
* Added test_thread testing for ostream_redirect segfault recreation
* fix: scoped_ostream_redirect str created outside gil
* Moved threading tests into test_iostream. Cleaned up some formatting. Deleted test_thread.{cpp,py}
* CI: few formatting fixes
* CI: yet another formatting fix
* CI: more formatting fixes. Removed unecessary comment
* Ignore 'warning C4702: unreachable code' in MSVC 2015
Co-authored-by: Nick Bridge <nick.bridge.chess@gmail.com>
Co-authored-by: Nick Bridge <nbridge@jumptrading.com>
Co-authored-by: Yannick Jadoul <yannick.jadoul@belgacom.net>
This commit is contained in:
@@ -216,3 +216,26 @@ def test_redirect_both(capfd):
|
||||
assert stderr == ""
|
||||
assert stream.getvalue() == msg
|
||||
assert stream2.getvalue() == msg2
|
||||
|
||||
|
||||
def test_threading():
|
||||
with m.ostream_redirect(stdout=True, stderr=False):
|
||||
# start some threads
|
||||
threads = []
|
||||
|
||||
# start some threads
|
||||
for _j in range(20):
|
||||
threads.append(m.TestThread())
|
||||
|
||||
# give the threads some time to fail
|
||||
threads[0].sleep()
|
||||
|
||||
# stop all the threads
|
||||
for t in threads:
|
||||
t.stop()
|
||||
|
||||
for t in threads:
|
||||
t.join()
|
||||
|
||||
# if a thread segfaults, we don't get here
|
||||
assert True
|
||||
|
||||
Reference in New Issue
Block a user