Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 21f7b8d

Browse filesBrowse files
committed
merge unittest into ExecutorTest
1 parent cdbd7c3 commit 21f7b8d
Copy full SHA for 21f7b8d

File tree

Expand file treeCollapse file tree

2 files changed

+40
-53
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+40
-53
lines changed

‎Lib/test/test_concurrent_futures/executor.py

Copy file name to clipboardExpand all lines: Lib/test/test_concurrent_futures/executor.py
+40Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import itertools
2+
from multiprocessing import Manager
13
import threading
24
import time
35
import weakref
@@ -69,6 +71,44 @@ def test_map_timeout(self):
6971

7072
self.assertEqual([None, None], results)
7173

74+
def test_map_args(self):
75+
with self.assertRaisesRegex(ValueError, "buffersize must be None or >= 1."):
76+
self.executor.map(bool, [], buffersize=0)
77+
with self.assertRaisesRegex(
78+
ValueError, "cannot specify both buffersize and timeout."
79+
):
80+
self.executor.map(bool, [], timeout=1, buffersize=1)
81+
82+
def test_map_infinite_iterable(self):
83+
results = self.executor.map(str, itertools.count(1), buffersize=1)
84+
self.assertEqual(next(iter(results)), "1")
85+
86+
def test_map_buffersize(self):
87+
manager = Manager()
88+
89+
for buffersize, iterable_size in [
90+
(1, 5),
91+
(5, 5),
92+
(10, 5),
93+
]:
94+
iterable = range(iterable_size)
95+
processed_elements = manager.list()
96+
97+
iterator = self.executor.map(
98+
processed_elements.append, iterable, buffersize=buffersize
99+
)
100+
time.sleep(1) # wait for buffered futures to finish
101+
self.assertSetEqual(
102+
set(processed_elements),
103+
set(range(min(buffersize, iterable_size))),
104+
)
105+
next(iterator)
106+
time.sleep(1) # wait for the created future to finish
107+
self.assertSetEqual(
108+
set(processed_elements),
109+
set(range(min(buffersize + 1, iterable_size))),
110+
)
111+
72112
def test_shutdown_race_issue12456(self):
73113
# Issue #12456: race condition at shutdown where trying to post a
74114
# sentinel in the call queue blocks (the queue is full while processes

‎Lib/test/test_concurrent_futures/test_pool.py

Copy file name to clipboardExpand all lines: Lib/test/test_concurrent_futures/test_pool.py
-53Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.