| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -203,6 +203,9 @@ def __init__(self, processes=None, initializer=None, initargs=(), | |||
| 203 | 203 | processes = os.cpu_count() or 1 | |
| 204 | 204 | if processes < 1: | |
| 205 | 205 | raise ValueError("Number of processes must be at least 1") | |
| 206 | + if maxtasksperchild is not None: | ||
| 207 | + if not isinstance(maxtasksperchild, int) or maxtasksperchild <= 0: | ||
| 208 | + raise ValueError("maxtasksperchild must be a positive int or None") | ||
| 206 | 209 | ||
| 207 | 210 | if initializer is not None and not callable(initializer): | |
| 208 | 211 | raise TypeError('initializer must be a callable') | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2863,6 +2863,11 @@ def test_pool_worker_lifetime_early_close(self): | |||
| 2863 | 2863 | for (j, res) in enumerate(results): | |
| 2864 | 2864 | self.assertEqual(res.get(), sqr(j)) | |
| 2865 | 2865 | ||
| 2866 | + def test_pool_maxtasksperchild_invalid(self): | ||
| 2867 | + for value in [0, -1, 0.5, "12"]: | ||
| 2868 | + with self.assertRaises(ValueError): | ||
| 2869 | + multiprocessing.Pool(3, maxtasksperchild=value) | ||
| 2870 | + | ||
| 2866 | 2871 | def test_worker_finalization_via_atexit_handler_of_multiprocessing(self): | |
| 2867 | 2872 | # tests cases against bpo-38744 and bpo-39360 | |
| 2868 | 2873 | cmd = '''if 1: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1 @@ | |||
| 1 | + Make :class:`multiprocessing.Pool` raise an exception if ``maxtasksperchild`` is not ``None`` or a positive int. | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments