(self)
| 1534 | self.assertEqual(proc.returncode, 0) |
| 1535 | |
| 1536 | def test_double_close_on_error(self): |
| 1537 | # Issue #18851 |
| 1538 | fds = [] |
| 1539 | def open_fds(): |
| 1540 | for i in range(20): |
| 1541 | fds.extend(os.pipe()) |
| 1542 | time.sleep(0.001) |
| 1543 | t = threading.Thread(target=open_fds) |
| 1544 | t.start() |
| 1545 | try: |
| 1546 | with self.assertRaises(OSError): |
| 1547 | subprocess.Popen(NONEXISTING_CMD, |
| 1548 | stdin=subprocess.PIPE, |
| 1549 | stdout=subprocess.PIPE, |
| 1550 | stderr=subprocess.PIPE) |
| 1551 | finally: |
| 1552 | t.join() |
| 1553 | exc = None |
| 1554 | for fd in fds: |
| 1555 | # If a double close occurred, some of those fds will |
| 1556 | # already have been closed by mistake, and os.close() |
| 1557 | # here will raise. |
| 1558 | try: |
| 1559 | os.close(fd) |
| 1560 | except OSError as e: |
| 1561 | exc = e |
| 1562 | if exc is not None: |
| 1563 | raise exc |
| 1564 | |
| 1565 | def test_threadsafe_wait(self): |
| 1566 | """Issue21291: Popen.wait() needs to be threadsafe for returncode.""" |
nothing calls this directly
no test coverage detected