Skip to content

Commit 755770c

Browse files
[debugging via CI] Temporarily raise with the task ID.
1 parent 605c802 commit 755770c

File tree

1 file changed

+27
-18
lines changed

1 file changed

+27
-18
lines changed

Lib/test/test_concurrent_futures/test_interpreter_pool.py

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -357,36 +357,45 @@ def test_blocking(self):
357357
ready = queues.create()
358358
blocker = queues.create()
359359

360-
def run(ready, blocker):
361-
raise Exception((ready.id, blocker.id))
362-
ready.put(None)
363-
blocker.get() # blocking
360+
def run(taskid, ready, blocker):
361+
ready.put_nowait(taskid)
362+
raise Exception(taskid)
363+
blocker.get(timeout=10) # blocking
364364

365365
numtasks = 10
366366
futures = []
367367
executor = self.executor_type()
368368
try:
369369
for i in range(numtasks):
370-
fut = executor.submit(run, ready, blocker)
370+
fut = executor.submit(run, i, ready, blocker)
371371
futures.append(fut)
372372
# assert len(executor._threads) == numtasks, len(executor._threads)
373-
ctx = None
373+
exceptions1 = []
374374
for i, fut in enumerate(futures, 1):
375375
try:
376376
fut.result(timeout=10)
377377
except Exception as exc:
378-
exc.__cause__ = ctx
379-
ctx = exc
380-
if i == numtasks:
381-
raise Exception((ready.id, blocker.id))
382-
# try:
383-
# # Wait for them all to be ready.
384-
# for i in range(numtasks):
385-
# ready.get() # blocking
386-
# finally:
387-
# # Unblock the workers.
388-
# for i in range(numtasks):
389-
# blocker.put_nowait(None)
378+
exceptions1.append(exc)
379+
exceptions2 = []
380+
try:
381+
# Wait for them all to be ready.
382+
for i in range(numtasks):
383+
try:
384+
ready.get(timeout=10) # blocking
385+
except interpreters.QueueEmpty as exc:
386+
exceptions2.append(exc)
387+
finally:
388+
# Unblock the workers.
389+
for i in range(numtasks):
390+
blocker.put_nowait(None)
391+
group1 = ExceptionGroup('futures', exceptions1) if exceptions1 else None
392+
group2 = ExceptionGroup('ready', exceptions2) if exceptions2 else None
393+
if group2:
394+
group2.__cause__ = group1
395+
raise group2
396+
elif group1:
397+
raise group1
398+
raise group
390399
finally:
391400
executor.shutdown(wait=True)
392401

0 commit comments

Comments
 (0)