| 1 |
cp -rf py3.9/examples . |
| 2 |
cp -rf py3.9/doc . |
| 3 |
cp -f py3.9/index.html . |
| 4 |
cp -rf Python-3.10.0a5/Modules/_multiprocessing Modules/_multiprocess |
| 5 |
cp -rf py3.9/_multiprocess _multiprocess |
| 6 |
cp -rf py3.9/multiprocess multiprocess |
| 7 |
cp Python-3.10.0a6/Lib/test/mp_*py multiprocess/tests |
| 8 |
cp Python-3.10.0a6/Lib/test/_test_multiprocessing.py multiprocess/tests/__init__.py |
| 9 |
|
| 10 |
# ---------------------------------------------------------------------- |
| 11 |
diff Python-3.10.0a5/Modules/_multiprocessing/semaphore.c Modules/_multiprocess/semaphore.c |
| 12 |
10c10 |
| 13 |
< #include "multiprocessing.h" |
| 14 |
--- |
| 15 |
> #include "multiprocess.h" |
| 16 |
33,34c33,34 |
| 17 |
< module _multiprocessing |
| 18 |
< class _multiprocessing.SemLock "SemLockObject *" "&_PyMp_SemLockType" |
| 19 |
--- |
| 20 |
> module _multiprocess |
| 21 |
> class _multiprocess.SemLock "SemLockObject *" "&_PyMp_SemLockType" |
| 22 |
78c78 |
| 23 |
< _multiprocessing.SemLock.acquire |
| 24 |
--- |
| 25 |
> _multiprocess.SemLock.acquire |
| 26 |
87c87 |
| 27 |
< _multiprocessing_SemLock_acquire_impl(SemLockObject *self, int blocking, |
| 28 |
--- |
| 29 |
> _multiprocess_SemLock_acquire_impl(SemLockObject *self, int blocking, |
| 30 |
169c169 |
| 31 |
< _multiprocessing.SemLock.release |
| 32 |
--- |
| 33 |
> _multiprocess.SemLock.release |
| 34 |
175c175 |
| 35 |
< _multiprocessing_SemLock_release_impl(SemLockObject *self) |
| 36 |
--- |
| 37 |
> _multiprocess_SemLock_release_impl(SemLockObject *self) |
| 38 |
230c230 |
| 39 |
< #ifndef HAVE_SEM_TIMEDWAIT |
| 40 |
--- |
| 41 |
> // ifndef HAVE_SEM_TIMEDWAIT |
| 42 |
291c291 |
| 43 |
< #endif /* !HAVE_SEM_TIMEDWAIT */ |
| 44 |
--- |
| 45 |
> // #endif /* !HAVE_SEM_TIMEDWAIT */ |
| 46 |
294c294 |
| 47 |
< _multiprocessing.SemLock.acquire |
| 48 |
--- |
| 49 |
> _multiprocess.SemLock.acquire |
| 50 |
303c303 |
| 51 |
< _multiprocessing_SemLock_acquire_impl(SemLockObject *self, int blocking, |
| 52 |
--- |
| 53 |
> _multiprocess_SemLock_acquire_impl(SemLockObject *self, int blocking, |
| 54 |
379c379 |
| 55 |
< _multiprocessing.SemLock.release |
| 56 |
--- |
| 57 |
> _multiprocess.SemLock.release |
| 58 |
385c385 |
| 59 |
< _multiprocessing_SemLock_release_impl(SemLockObject *self) |
| 60 |
--- |
| 61 |
> _multiprocess_SemLock_release_impl(SemLockObject *self) |
| 62 |
471c471 |
| 63 |
< _multiprocessing.SemLock.__new__ |
| 64 |
--- |
| 65 |
> _multiprocess.SemLock.__new__ |
| 66 |
482c482 |
| 67 |
< _multiprocessing_SemLock_impl(PyTypeObject *type, int kind, int value, |
| 68 |
--- |
| 69 |
> _multiprocess_SemLock_impl(PyTypeObject *type, int kind, int value, |
| 70 |
530c530 |
| 71 |
< _multiprocessing.SemLock._rebuild |
| 72 |
--- |
| 73 |
> _multiprocess.SemLock._rebuild |
| 74 |
541c541 |
| 75 |
< _multiprocessing_SemLock__rebuild_impl(PyTypeObject *type, SEM_HANDLE handle, |
| 76 |
--- |
| 77 |
> _multiprocess_SemLock__rebuild_impl(PyTypeObject *type, SEM_HANDLE handle, |
| 78 |
578c578 |
| 79 |
< _multiprocessing.SemLock._count |
| 80 |
--- |
| 81 |
> _multiprocess.SemLock._count |
| 82 |
584c584 |
| 83 |
< _multiprocessing_SemLock__count_impl(SemLockObject *self) |
| 84 |
--- |
| 85 |
> _multiprocess_SemLock__count_impl(SemLockObject *self) |
| 86 |
591c591 |
| 87 |
< _multiprocessing.SemLock._is_mine |
| 88 |
--- |
| 89 |
> _multiprocess.SemLock._is_mine |
| 90 |
597c597 |
| 91 |
< _multiprocessing_SemLock__is_mine_impl(SemLockObject *self) |
| 92 |
--- |
| 93 |
> _multiprocess_SemLock__is_mine_impl(SemLockObject *self) |
| 94 |
605c605 |
| 95 |
< _multiprocessing.SemLock._get_value |
| 96 |
--- |
| 97 |
> _multiprocess.SemLock._get_value |
| 98 |
611c611 |
| 99 |
< _multiprocessing_SemLock__get_value_impl(SemLockObject *self) |
| 100 |
--- |
| 101 |
> _multiprocess_SemLock__get_value_impl(SemLockObject *self) |
| 102 |
630c630 |
| 103 |
< _multiprocessing.SemLock._is_zero |
| 104 |
--- |
| 105 |
> _multiprocess.SemLock._is_zero |
| 106 |
636c636 |
| 107 |
< _multiprocessing_SemLock__is_zero_impl(SemLockObject *self) |
| 108 |
--- |
| 109 |
> _multiprocess_SemLock__is_zero_impl(SemLockObject *self) |
| 110 |
658c658 |
| 111 |
< _multiprocessing.SemLock._after_fork |
| 112 |
--- |
| 113 |
> _multiprocess.SemLock._after_fork |
| 114 |
664c664 |
| 115 |
< _multiprocessing_SemLock__after_fork_impl(SemLockObject *self) |
| 116 |
--- |
| 117 |
> _multiprocess_SemLock__after_fork_impl(SemLockObject *self) |
| 118 |
672c672 |
| 119 |
< _multiprocessing.SemLock.__enter__ |
| 120 |
--- |
| 121 |
> _multiprocess.SemLock.__enter__ |
| 122 |
678c678 |
| 123 |
< _multiprocessing_SemLock___enter___impl(SemLockObject *self) |
| 124 |
--- |
| 125 |
> _multiprocess_SemLock___enter___impl(SemLockObject *self) |
| 126 |
681c681 |
| 127 |
< return _multiprocessing_SemLock_acquire_impl(self, 1, Py_None); |
| 128 |
--- |
| 129 |
> return _multiprocess_SemLock_acquire_impl(self, 1, Py_None); |
| 130 |
685c685 |
| 131 |
< _multiprocessing.SemLock.__exit__ |
| 132 |
--- |
| 133 |
> _multiprocess.SemLock.__exit__ |
| 134 |
696c696 |
| 135 |
< _multiprocessing_SemLock___exit___impl(SemLockObject *self, |
| 136 |
--- |
| 137 |
> _multiprocess_SemLock___exit___impl(SemLockObject *self, |
| 138 |
701c701 |
| 139 |
< return _multiprocessing_SemLock_release_impl(self); |
| 140 |
--- |
| 141 |
> return _multiprocess_SemLock_release_impl(self); |
| 142 |
744c744 |
| 143 |
< /* tp_name */ "_multiprocessing.SemLock", |
| 144 |
--- |
| 145 |
> /* tp_name */ "_multiprocess.SemLock", |
| 146 |
780c780 |
| 147 |
< /* tp_new */ _multiprocessing_SemLock, |
| 148 |
--- |
| 149 |
> /* tp_new */ _multiprocess_SemLock, |
| 150 |
# ---------------------------------------------------------------------- |
| 151 |
$ mv multiprocessing.c multiprocess.c |
| 152 |
$ mv multiprocessing.h multiprocess.h |
| 153 |
# ---------------------------------------------------------------------- |
| 154 |
diff Python-3.10.0a5/Lib/multiprocessing/resource_tracker.py Python-3.10.0a6/Lib/multiprocessing/resource_tracker.py |
| 155 |
39a40,48 |
| 156 |
> # Use sem_unlink() to clean up named semaphores. |
| 157 |
> # |
| 158 |
> # sem_unlink() may be missing if the Python build process detected the |
| 159 |
> # absence of POSIX named semaphores. In that case, no named semaphores were |
| 160 |
> # ever opened, so no cleanup would be necessary. |
| 161 |
> if hasattr(_multiprocessing, 'sem_unlink'): |
| 162 |
> _CLEANUP_FUNCS.update({ |
| 163 |
> 'semaphore': _multiprocessing.sem_unlink, |
| 164 |
> }) |
| 165 |
41d49 |
| 166 |
< 'semaphore': _multiprocessing.sem_unlink, |
| 167 |
# ---------------------------------------------------------------------- |
| 168 |
diff Python-3.10.0a6/Lib/test/_test_multiprocessing.py multiprocess/tests/__init__.py |
| 169 |
23c23 |
| 170 |
< import pickle |
| 171 |
--- |
| 172 |
> import pickle #XXX: use dill? |
| 173 |
40c40 |
| 174 |
< support.skip_if_broken_multiprocessing_synchronize() |
| 175 |
--- |
| 176 |
> import_helper.import_module('multiprocess.synchronize') |
| 177 |
43,48c43,49 |
| 178 |
< import multiprocessing.connection |
| 179 |
< import multiprocessing.dummy |
| 180 |
< import multiprocessing.heap |
| 181 |
< import multiprocessing.managers |
| 182 |
< import multiprocessing.pool |
| 183 |
< import multiprocessing.queues |
| 184 |
--- |
| 185 |
> import multiprocess as multiprocessing |
| 186 |
> import multiprocess.connection |
| 187 |
> import multiprocess.dummy |
| 188 |
> import multiprocess.heap |
| 189 |
> import multiprocess.managers |
| 190 |
> import multiprocess.pool |
| 191 |
> import multiprocess.queues |
| 192 |
50c51 |
| 193 |
< from multiprocessing import util |
| 194 |
--- |
| 195 |
> from multiprocess import util |
| 196 |
53c54 |
| 197 |
< from multiprocessing import reduction |
| 198 |
--- |
| 199 |
> from multiprocess import reduction |
| 200 |
59c60 |
| 201 |
< from multiprocessing.sharedctypes import Value, copy |
| 202 |
--- |
| 203 |
> from multiprocess.sharedctypes import Value, copy |
| 204 |
65c66 |
| 205 |
< from multiprocessing import shared_memory |
| 206 |
--- |
| 207 |
> from multiprocess import shared_memory |
| 208 |
93c94 |
| 209 |
< from multiprocessing import resource_tracker |
| 210 |
--- |
| 211 |
> from multiprocess import resource_tracker |
| 212 |
121c122 |
| 213 |
< from multiprocessing.connection import wait |
| 214 |
--- |
| 215 |
> from multiprocess.connection import wait |
| 216 |
134c135 |
| 217 |
< PRELOAD = ['__main__', 'test.test_multiprocessing_forkserver'] |
| 218 |
--- |
| 219 |
> PRELOAD = ['__main__', 'test_multiprocessing_forkserver'] |
| 220 |
289c290 |
| 221 |
< from multiprocessing.process import parent_process |
| 222 |
--- |
| 223 |
> from multiprocess.process import parent_process |
| 224 |
292c293 |
| 225 |
< def test_parent_process(self): |
| 226 |
--- |
| 227 |
> def _test_parent_process(self): |
| 228 |
325c326 |
| 229 |
< from multiprocessing.process import parent_process |
| 230 |
--- |
| 231 |
> from multiprocess.process import parent_process |
| 232 |
492a494 |
| 233 |
> @unittest.skipIf(True, "fails with is_dill(obj, child=True)") |
| 234 |
744c746 |
| 235 |
< from multiprocessing.forkserver import _forkserver |
| 236 |
--- |
| 237 |
> from multiprocess.forkserver import _forkserver |
| 238 |
833,834c835,836 |
| 239 |
< self.assertIn("test_multiprocessing.py", err) |
| 240 |
< self.assertIn("1/0 # MARKER", err) |
| 241 |
--- |
| 242 |
> self.assertIn("__init__.py", err) |
| 243 |
> #self.assertIn("1/0 # MARKER", err) #FIXME |
| 244 |
1123c1125 |
| 245 |
< import multiprocessing |
| 246 |
--- |
| 247 |
> import multiprocess as multiprocessing |
| 248 |
2016c2018 |
| 249 |
< self.skipTest("requires multiprocessing.sharedctypes") |
| 250 |
--- |
| 251 |
> self.skipTest("requires multiprocess.sharedctypes") |
| 252 |
2582a2585 |
| 253 |
> @unittest.skipIf(True, "fails with is_dill(obj, child=True)") |
| 254 |
2624a2628 |
| 255 |
> @unittest.skipIf(True, "fails with is_dill(obj, child=True)") |
| 256 |
2722,2723c2726,2727 |
| 257 |
< def test_unpickleable_result(self): |
| 258 |
< from multiprocessing.pool import MaybeEncodingError |
| 259 |
--- |
| 260 |
> def _test_unpickleable_result(self): |
| 261 |
> from multiprocess.pool import MaybeEncodingError |
| 262 |
2811c2815 |
| 263 |
< from multiprocessing.managers import BaseManager, BaseProxy, RemoteError |
| 264 |
--- |
| 265 |
> from multiprocess.managers import BaseManager, BaseProxy, RemoteError |
| 266 |
3454c3458 |
| 267 |
< from multiprocessing import resource_sharer |
| 268 |
--- |
| 269 |
> from multiprocess import resource_sharer |
| 270 |
3699c3703 |
| 271 |
< self.skipTest("requires multiprocessing.sharedctypes") |
| 272 |
--- |
| 273 |
> self.skipTest("requires multiprocess.sharedctypes") |
| 274 |
3749c3753 |
| 275 |
< @unittest.skipUnless(HAS_SHMEM, "requires multiprocessing.shared_memory") |
| 276 |
--- |
| 277 |
> @unittest.skipUnless(HAS_SHMEM, "requires multiprocess.shared_memory") |
| 278 |
4310,4312c4314,4316 |
| 279 |
< modules = ['multiprocessing.' + m for m in modules] |
| 280 |
< modules.remove('multiprocessing.__init__') |
| 281 |
< modules.append('multiprocessing') |
| 282 |
--- |
| 283 |
> modules = ['multiprocess.' + m for m in modules] |
| 284 |
> modules.remove('multiprocess.__init__') |
| 285 |
> modules.append('multiprocess') |
| 286 |
4318,4320c4322,4324 |
| 287 |
< modules.remove('multiprocessing.popen_fork') |
| 288 |
< modules.remove('multiprocessing.popen_forkserver') |
| 289 |
< modules.remove('multiprocessing.popen_spawn_posix') |
| 290 |
--- |
| 291 |
> modules.remove('multiprocess.popen_fork') |
| 292 |
> modules.remove('multiprocess.popen_forkserver') |
| 293 |
> modules.remove('multiprocess.popen_spawn_posix') |
| 294 |
4322c4326 |
| 295 |
< modules.remove('multiprocessing.popen_spawn_win32') |
| 296 |
--- |
| 297 |
> modules.remove('multiprocess.popen_spawn_win32') |
| 298 |
4324c4328 |
| 299 |
< modules.remove('multiprocessing.popen_forkserver') |
| 300 |
--- |
| 301 |
> modules.remove('multiprocess.popen_forkserver') |
| 302 |
4328c4332 |
| 303 |
< modules.remove('multiprocessing.sharedctypes') |
| 304 |
--- |
| 305 |
> modules.remove('multiprocess.sharedctypes') |
| 306 |
4610c4614 |
| 307 |
< from multiprocessing.connection import wait |
| 308 |
--- |
| 309 |
> from multiprocess.connection import wait |
| 310 |
4650c4654 |
| 311 |
< from multiprocessing.connection import wait |
| 312 |
--- |
| 313 |
> from multiprocess.connection import wait |
| 314 |
4691c4695 |
| 315 |
< from multiprocessing.connection import wait |
| 316 |
--- |
| 317 |
> from multiprocess.connection import wait |
| 318 |
4719c4723 |
| 319 |
< from multiprocessing.connection import wait |
| 320 |
--- |
| 321 |
> from multiprocess.connection import wait |
| 322 |
4762c4766 |
| 323 |
< from multiprocessing.connection import wait |
| 324 |
--- |
| 325 |
> from multiprocess.connection import wait |
| 326 |
4810c4814 |
| 327 |
< def test_flags(self): |
| 328 |
--- |
| 329 |
> def _test_flags(self): |
| 330 |
4813c4817 |
| 331 |
< prog = ('from test._test_multiprocessing import TestFlags; ' + |
| 332 |
--- |
| 333 |
> prog = ('from multiprocess.tests import TestFlags; ' + |
| 334 |
5115c5119 |
| 335 |
< def test_resource_tracker(self): |
| 336 |
--- |
| 337 |
> def _test_resource_tracker(self): |
| 338 |
5121,5123c5125,5127 |
| 339 |
< import multiprocessing as mp |
| 340 |
< from multiprocessing import resource_tracker |
| 341 |
< from multiprocessing.shared_memory import SharedMemory |
| 342 |
--- |
| 343 |
> import multiprocess as mp |
| 344 |
> from multiprocess import resource_tracker |
| 345 |
> from multiprocess.shared_memory import SharedMemory |
| 346 |
5192c5196 |
| 347 |
< from multiprocessing.resource_tracker import _resource_tracker |
| 348 |
--- |
| 349 |
> from multiprocess.resource_tracker import _resource_tracker |
| 350 |
5240c5244 |
| 351 |
< from multiprocessing.resource_tracker import _resource_tracker |
| 352 |
--- |
| 353 |
> from multiprocess.resource_tracker import _resource_tracker |
| 354 |
5249c5253 |
| 355 |
< from multiprocessing.resource_tracker import _resource_tracker |
| 356 |
--- |
| 357 |
> from multiprocess.resource_tracker import _resource_tracker |
| 358 |
5416c5420 |
| 359 |
< support.print_warning(f"multiprocessing.Manager still has " |
| 360 |
--- |
| 361 |
> support.print_warning(f"multiprocess.Manager still has " |
| 362 |
5694c5698 |
| 363 |
< support.print_warning(f"multiprocessing.Manager still has " |
| 364 |
--- |
| 365 |
> support.print_warning(f"multiprocess.Manager still has " |
| 366 |
# ---------------------------------------------------------------------- |
| 367 |
diff Python-3.10.0a7/Lib/test/_test_multiprocessing.py Python-3.10.0a6/Lib/test/_test_multiprocessing.py |
| 368 |
829c829 |
| 369 |
< with open(testfn, encoding="utf-8") as f: |
| 370 |
--- |
| 371 |
> with open(testfn, 'r') as f: |
| 372 |
839c839 |
| 373 |
< sys.stderr = open(fd, 'w', encoding="utf-8", closefd=False) |
| 374 |
--- |
| 375 |
> sys.stderr = open(fd, 'w', closefd=False) |
| 376 |
846c846 |
| 377 |
< sys.stderr = open(fd, 'w', encoding="utf-8", closefd=False) |
| 378 |
--- |
| 379 |
> sys.stderr = open(fd, 'w', closefd=False) |
| 380 |
867c867 |
| 381 |
< with open(testfn, encoding="utf-8") as f: |
| 382 |
--- |
| 383 |
> with open(testfn, 'r') as f: |
| 384 |
1121c1121 |
| 385 |
< with open(module_name + '.py', 'w', encoding="utf-8") as f: |
| 386 |
--- |
| 387 |
> with open(module_name + '.py', 'w') as f: |
| 388 |
diff Python-3.10.0a7/Lib/multiprocessing/util.py Python-3.10.0a6/Lib/multiprocessing/util.py |
| 389 |
422c422 |
| 390 |
< sys.stdin = open(fd, encoding="utf-8", closefd=False) |
| 391 |
--- |
| 392 |
> sys.stdin = open(fd, closefd=False) |
| 393 |
# ---------------------------------------------------------------------- |
| 394 |
diff Python-3.10.0b1/Lib/multiprocessing/managers.py Python-3.10.0a7/Lib/multiprocessing/managers.py |
| 395 |
195,196c195,199 |
| 396 |
< def _handle_request(self, c): |
| 397 |
< request = None |
| 398 |
--- |
| 399 |
> def handle_request(self, c): |
| 400 |
> ''' |
| 401 |
> Handle a new connection |
| 402 |
> ''' |
| 403 |
> funcname = result = request = None |
| 404 |
213d215 |
| 405 |
< |
| 406 |
225,235c227 |
| 407 |
< def handle_request(self, conn): |
| 408 |
< ''' |
| 409 |
< Handle a new connection |
| 410 |
< ''' |
| 411 |
< try: |
| 412 |
< self._handle_request(conn) |
| 413 |
< except SystemExit: |
| 414 |
< # Server.serve_client() calls sys.exit(0) on EOF |
| 415 |
< pass |
| 416 |
< finally: |
| 417 |
< conn.close() |
| 418 |
--- |
| 419 |
> c.close() |
| 420 |
# ---------------------------------------------------------------------- |
| 421 |
diff Python-3.10.0b1/Lib/multiprocessing/managers.py Python-3.10.0rc2/Lib/multiprocessing/managers.py |
| 422 |
11,12c11 |
| 423 |
< __all__ = [ 'BaseManager', 'SyncManager', 'BaseProxy', 'Token', |
| 424 |
< 'SharedMemoryManager' ] |
| 425 |
--- |
| 426 |
> __all__ = [ 'BaseManager', 'SyncManager', 'BaseProxy', 'Token' ] |
| 427 |
38d36 |
| 428 |
< HAS_SHMEM = True |
| 429 |
40a39,41 |
| 430 |
> else: |
| 431 |
> HAS_SHMEM = True |
| 432 |
> __all__.append('SharedMemoryManager') |
| 433 |
970c971 |
| 434 |
< exposed=None, incref=True): |
| 435 |
--- |
| 436 |
> exposed=None, incref=True, manager_owned=False): |
| 437 |
990c991 |
| 438 |
< incref=incref) |
| 439 |
--- |
| 440 |
> incref=incref, manager_owned=manager_owned) |
| 441 |
# ---------------------------------------------------------------------- |
| 442 |
diff Python-3.10.0b1/Lib/test/_test_multiprocessing.py Python-3.10.0rc2/Lib/test/_test_multiprocessing.py |
| 443 |
2288a2289,2298 |
| 444 |
> def test_nested_queue(self): |
| 445 |
> a = self.list() # Test queue inside list |
| 446 |
> a.append(self.Queue()) |
| 447 |
> a[0].put(123) |
| 448 |
> self.assertEqual(a[0].get(), 123) |
| 449 |
> b = self.dict() # Test queue inside dict |
| 450 |
> b[0] = self.Queue() |
| 451 |
> b[0].put(456) |
| 452 |
> self.assertEqual(b[0].get(), 456) |
| 453 |
> |
| 454 |
3782d3791 |
| 455 |
< self.assertEqual(sms.size, sms2.size) |
| 456 |
# ---------------------------------------------------------------------- |
| 457 |
diff Python-3.10.0rc2/Lib/test/_test_multiprocessing.py Python-3.10.0/Lib//test/_test_multiprocessing.py |
| 458 |
3773a3774,3779 |
| 459 |
> def _new_shm_name(self, prefix): |
| 460 |
> # Add a PID to the name of a POSIX shared memory object to allow |
| 461 |
> # running multiprocessing tests (test_multiprocessing_fork, |
| 462 |
> # test_multiprocessing_spawn, etc) in parallel. |
| 463 |
> return prefix + str(os.getpid()) |
| 464 |
> |
| 465 |
3775c3781,3782 |
| 466 |
< sms = shared_memory.SharedMemory('test01_tsmb', create=True, size=512) |
| 467 |
--- |
| 468 |
> name_tsmb = self._new_shm_name('test01_tsmb') |
| 469 |
> sms = shared_memory.SharedMemory(name_tsmb, create=True, size=512) |
| 470 |
3779c3786 |
| 471 |
< self.assertEqual(sms.name, 'test01_tsmb') |
| 472 |
--- |
| 473 |
> self.assertEqual(sms.name, name_tsmb) |
| 474 |
3799c3806 |
| 475 |
< also_sms = shared_memory.SharedMemory('test01_tsmb') |
| 476 |
--- |
| 477 |
> also_sms = shared_memory.SharedMemory(name_tsmb) |
| 478 |
3804c3811 |
| 479 |
< same_sms = shared_memory.SharedMemory('test01_tsmb', size=20*sms.size) |
| 480 |
--- |
| 481 |
> same_sms = shared_memory.SharedMemory(name_tsmb, size=20*sms.size) |
| 482 |
3822c3829 |
| 483 |
< names = ['test01_fn', 'test02_fn'] |
| 484 |
--- |
| 485 |
> names = [self._new_shm_name('test01_fn'), self._new_shm_name('test02_fn')] |
| 486 |
3843a3851,3856 |
| 487 |
> name_dblunlink = self._new_shm_name('test01_dblunlink') |
| 488 |
> sms_uno = shared_memory.SharedMemory( |
| 489 |
> name_dblunlink, |
| 490 |
> create=True, |
| 491 |
> size=5000 |
| 492 |
> ) |
| 493 |
3845,3850d3857 |
| 494 |
< sms_uno = shared_memory.SharedMemory( |
| 495 |
< 'test01_dblunlink', |
| 496 |
< create=True, |
| 497 |
< size=5000 |
| 498 |
< ) |
| 499 |
< |
| 500 |
3854c3861 |
| 501 |
< sms_duo = shared_memory.SharedMemory('test01_dblunlink') |
| 502 |
--- |
| 503 |
> sms_duo = shared_memory.SharedMemory(name_dblunlink) |
| 504 |
3866c3873 |
| 505 |
< 'test01_tsmb', |
| 506 |
--- |
| 507 |
> name_tsmb, |
| 508 |
3880c3887 |
| 509 |
< ok_if_exists_sms = OptionalAttachSharedMemory('test01_tsmb') |
| 510 |
--- |
| 511 |
> ok_if_exists_sms = OptionalAttachSharedMemory(name_tsmb) |
| 512 |
4085c4092,4093 |
| 513 |
< sl_copy = shared_memory.ShareableList(sl, name='test03_duplicate') |
| 514 |
--- |
| 515 |
> name_duplicate = self._new_shm_name('test03_duplicate') |
| 516 |
> sl_copy = shared_memory.ShareableList(sl, name=name_duplicate) |
| 517 |
4088c4096 |
| 518 |
< self.assertEqual('test03_duplicate', sl_copy.shm.name) |
| 519 |
--- |
| 520 |
> self.assertEqual(name_duplicate, sl_copy.shm.name) |
| 521 |
# ---------------------------------------------------------------------- |
| 522 |
diff Python-3.10.0/Lib/test/_test_multiprocessing.py py3.10/multiprocess/tests/__init__.py |
| 523 |
3826c3830 |
| 524 |
> 'multiprocessing.shared_memory._make_filename') as mock_make_filename: |
| 525 |
--- |
| 526 |
< 'multiprocess.shared_memory._make_filename') as mock_make_filename: |
| 527 |
# ---------------------------------------------------------------------- |
| 528 |
diff Python-3.10.0/Lib/test/_test_multiprocessing.py Python-3.10.1/Lib/test/_test_multiprocessing.py |
| 529 |
613a614 |
| 530 |
> gc.collect() # For PyPy or other GCs. |
| 531 |
2669a2671 |
| 532 |
> gc.collect() # For PyPy or other GCs. |
| 533 |
3794,3800d3795 |
| 534 |
< # Test pickling |
| 535 |
< sms.buf[0:6] = b'pickle' |
| 536 |
< pickled_sms = pickle.dumps(sms) |
| 537 |
< sms2 = pickle.loads(pickled_sms) |
| 538 |
< self.assertEqual(sms.name, sms2.name) |
| 539 |
< self.assertEqual(bytes(sms.buf[0:6]), bytes(sms2.buf[0:6]), b'pickle') |
| 540 |
< |
| 541 |
3898a3894,3916 |
| 542 |
> def test_shared_memory_recreate(self): |
| 543 |
> # Test if shared memory segment is created properly, |
| 544 |
> # when _make_filename returns an existing shared memory segment name |
| 545 |
> with unittest.mock.patch( |
| 546 |
> 'multiprocessing.shared_memory._make_filename') as mock_make_filename: |
| 547 |
> |
| 548 |
> NAME_PREFIX = shared_memory._SHM_NAME_PREFIX |
| 549 |
> names = ['test01_fn', 'test02_fn'] |
| 550 |
> # Prepend NAME_PREFIX which can be '/psm_' or 'wnsm_', necessary |
| 551 |
> # because some POSIX compliant systems require name to start with / |
| 552 |
> names = [NAME_PREFIX + name for name in names] |
| 553 |
> |
| 554 |
> mock_make_filename.side_effect = names |
| 555 |
> shm1 = shared_memory.SharedMemory(create=True, size=1) |
| 556 |
> self.addCleanup(shm1.unlink) |
| 557 |
> self.assertEqual(shm1._name, names[0]) |
| 558 |
> |
| 559 |
> mock_make_filename.side_effect = names |
| 560 |
> shm2 = shared_memory.SharedMemory(create=True, size=1) |
| 561 |
> self.addCleanup(shm2.unlink) |
| 562 |
> self.assertEqual(shm2._name, names[1]) |
| 563 |
> |
| 564 |
> def test_invalid_shared_memory_cration(self): |
| 565 |
3910a3929,3969 |
| 566 |
> def test_shared_memory_pickle_unpickle(self): |
| 567 |
> for proto in range(pickle.HIGHEST_PROTOCOL + 1): |
| 568 |
> with self.subTest(proto=proto): |
| 569 |
> sms = shared_memory.SharedMemory(create=True, size=512) |
| 570 |
> self.addCleanup(sms.unlink) |
| 571 |
> sms.buf[0:6] = b'pickle' |
| 572 |
> |
| 573 |
> # Test pickling |
| 574 |
> pickled_sms = pickle.dumps(sms, protocol=proto) |
| 575 |
> |
| 576 |
> # Test unpickling |
| 577 |
> sms2 = pickle.loads(pickled_sms) |
| 578 |
> self.assertIsInstance(sms2, shared_memory.SharedMemory) |
| 579 |
> self.assertEqual(sms.name, sms2.name) |
| 580 |
> self.assertEqual(bytes(sms.buf[0:6]), b'pickle') |
| 581 |
> self.assertEqual(bytes(sms2.buf[0:6]), b'pickle') |
| 582 |
> |
| 583 |
> # Test that unpickled version is still the same SharedMemory |
| 584 |
> sms.buf[0:6] = b'newval' |
| 585 |
> self.assertEqual(bytes(sms.buf[0:6]), b'newval') |
| 586 |
> self.assertEqual(bytes(sms2.buf[0:6]), b'newval') |
| 587 |
> |
| 588 |
> sms2.buf[0:6] = b'oldval' |
| 589 |
> self.assertEqual(bytes(sms.buf[0:6]), b'oldval') |
| 590 |
> self.assertEqual(bytes(sms2.buf[0:6]), b'oldval') |
| 591 |
> |
| 592 |
> def test_shared_memory_pickle_unpickle_dead_object(self): |
| 593 |
> for proto in range(pickle.HIGHEST_PROTOCOL + 1): |
| 594 |
> with self.subTest(proto=proto): |
| 595 |
> sms = shared_memory.SharedMemory(create=True, size=512) |
| 596 |
> sms.buf[0:6] = b'pickle' |
| 597 |
> pickled_sms = pickle.dumps(sms, protocol=proto) |
| 598 |
> |
| 599 |
> # Now, we are going to kill the original object. |
| 600 |
> # So, unpickled one won't be able to attach to it. |
| 601 |
> sms.close() |
| 602 |
> sms.unlink() |
| 603 |
> |
| 604 |
> with self.assertRaises(FileNotFoundError): |
| 605 |
> pickle.loads(pickled_sms) |
| 606 |
> |
| 607 |
4128,4129c4187,4222 |
| 608 |
< sl = shared_memory.ShareableList(range(10)) |
| 609 |
< self.addCleanup(sl.shm.unlink) |
| 610 |
--- |
| 611 |
> for proto in range(pickle.HIGHEST_PROTOCOL + 1): |
| 612 |
> with self.subTest(proto=proto): |
| 613 |
> sl = shared_memory.ShareableList(range(10)) |
| 614 |
> self.addCleanup(sl.shm.unlink) |
| 615 |
> |
| 616 |
> serialized_sl = pickle.dumps(sl, protocol=proto) |
| 617 |
> deserialized_sl = pickle.loads(serialized_sl) |
| 618 |
> self.assertIsInstance( |
| 619 |
> deserialized_sl, shared_memory.ShareableList) |
| 620 |
> self.assertEqual(deserialized_sl[-1], 9) |
| 621 |
> self.assertIsNot(sl, deserialized_sl) |
| 622 |
> |
| 623 |
> deserialized_sl[4] = "changed" |
| 624 |
> self.assertEqual(sl[4], "changed") |
| 625 |
> sl[3] = "newvalue" |
| 626 |
> self.assertEqual(deserialized_sl[3], "newvalue") |
| 627 |
> |
| 628 |
> larger_sl = shared_memory.ShareableList(range(400)) |
| 629 |
> self.addCleanup(larger_sl.shm.unlink) |
| 630 |
> serialized_larger_sl = pickle.dumps(larger_sl, protocol=proto) |
| 631 |
> self.assertEqual(len(serialized_sl), len(serialized_larger_sl)) |
| 632 |
> larger_sl.shm.close() |
| 633 |
> |
| 634 |
> deserialized_sl.shm.close() |
| 635 |
> sl.shm.close() |
| 636 |
> |
| 637 |
> def test_shared_memory_ShareableList_pickling_dead_object(self): |
| 638 |
> for proto in range(pickle.HIGHEST_PROTOCOL + 1): |
| 639 |
> with self.subTest(proto=proto): |
| 640 |
> sl = shared_memory.ShareableList(range(10)) |
| 641 |
> serialized_sl = pickle.dumps(sl, protocol=proto) |
| 642 |
> |
| 643 |
> # Now, we are going to kill the original object. |
| 644 |
> # So, unpickled one won't be able to attach to it. |
| 645 |
> sl.shm.close() |
| 646 |
> sl.shm.unlink() |
| 647 |
4131,4150c4224,4225 |
| 648 |
< serialized_sl = pickle.dumps(sl) |
| 649 |
< deserialized_sl = pickle.loads(serialized_sl) |
| 650 |
< self.assertTrue( |
| 651 |
< isinstance(deserialized_sl, shared_memory.ShareableList) |
| 652 |
< ) |
| 653 |
< self.assertTrue(deserialized_sl[-1], 9) |
| 654 |
< self.assertFalse(sl is deserialized_sl) |
| 655 |
< deserialized_sl[4] = "changed" |
| 656 |
< self.assertEqual(sl[4], "changed") |
| 657 |
< |
| 658 |
< # Verify data is not being put into the pickled representation. |
| 659 |
< name = 'a' * len(sl.shm.name) |
| 660 |
< larger_sl = shared_memory.ShareableList(range(400)) |
| 661 |
< self.addCleanup(larger_sl.shm.unlink) |
| 662 |
< serialized_larger_sl = pickle.dumps(larger_sl) |
| 663 |
< self.assertTrue(len(serialized_sl) == len(serialized_larger_sl)) |
| 664 |
< larger_sl.shm.close() |
| 665 |
< |
| 666 |
< deserialized_sl.shm.close() |
| 667 |
< sl.shm.close() |
| 668 |
--- |
| 669 |
> with self.assertRaises(FileNotFoundError): |
| 670 |
> pickle.loads(serialized_sl) |
| 671 |
4186a4262,4268 |
| 672 |
> # Without this line it was raising warnings like: |
| 673 |
> # UserWarning: resource_tracker: |
| 674 |
> # There appear to be 1 leaked shared_memory |
| 675 |
> # objects to clean up at shutdown |
| 676 |
> # See: https://bugs.python.org/issue45209 |
| 677 |
> resource_tracker.unregister(f"/{name}", "shared_memory") |
| 678 |
> |
| 679 |
4196c4278 |
| 680 |
< # |
| 681 |
--- |
| 682 |
> # Test to verify that `Finalize` works. |
| 683 |
4207a4290 |
| 684 |
> gc.collect() # For PyPy or other GCs. |
| 685 |
4218a4302 |
| 686 |
> gc.collect() # For PyPy or other GCs. |
| 687 |
4224a4309 |
| 688 |
> gc.collect() # For PyPy or other GCs. |
| 689 |
# ---------------------------------------------------------------------- |
| 690 |
$ diff Python-3.10.2/Lib/test/_test_multiprocessing.py Python-3.10.4/Lib/test/_test_multiprocessing.py |
| 691 |
75a76,81 |
| 692 |
> if support.check_sanitizer(address=True): |
| 693 |
> # bpo-45200: Skip multiprocessing tests if Python is built with ASAN to |
| 694 |
> # work around a libasan race condition: dead lock in pthread_create(). |
| 695 |
> raise unittest.SkipTest("libasan has a pthread_create() dead lock") |
| 696 |
> |
| 697 |
> |
| 698 |
# ---------------------------------------------------------------------- |
| 699 |
diff Python-3.10.4/Lib/multiprocessing/managers.py Python-3.10.5/Lib/multiprocessing/managers.py |
| 700 |
680c680 |
| 701 |
< process.join(timeout=0.1) |
| 702 |
--- |
| 703 |
> process.join(timeout=1.0) |
| 704 |
diff Python-3.10.4/Lib/multiprocessing/queues.py Python-3.10.5/Lib/multiprocessing/queues.py |
| 705 |
142,148c142,145 |
| 706 |
< try: |
| 707 |
< self._reader.close() |
| 708 |
< finally: |
| 709 |
< close = self._close |
| 710 |
< if close: |
| 711 |
< self._close = None |
| 712 |
< close() |
| 713 |
--- |
| 714 |
> close = self._close |
| 715 |
> if close: |
| 716 |
> self._close = None |
| 717 |
> close() |
| 718 |
172,173c169,171 |
| 719 |
< self._wlock, self._writer.close, self._ignore_epipe, |
| 720 |
< self._on_queue_feeder_error, self._sem), |
| 721 |
--- |
| 722 |
> self._wlock, self._reader.close, self._writer.close, |
| 723 |
> self._ignore_epipe, self._on_queue_feeder_error, |
| 724 |
> self._sem), |
| 725 |
214,215c212,213 |
| 726 |
< def _feed(buffer, notempty, send_bytes, writelock, close, ignore_epipe, |
| 727 |
< onerror, queue_sem): |
| 728 |
--- |
| 729 |
> def _feed(buffer, notempty, send_bytes, writelock, reader_close, |
| 730 |
> writer_close, ignore_epipe, onerror, queue_sem): |
| 731 |
241c239,240 |
| 732 |
< close() |
| 733 |
--- |
| 734 |
> reader_close() |
| 735 |
> writer_close() |
| 736 |
diff Python-3.10.4/Lib/multiprocessing/util.py Python-3.10.5/Lib/multiprocessing/util.py |
| 737 |
123c123 |
| 738 |
< raise TypeError('address type of {address!r} unrecognized') |
| 739 |
--- |
| 740 |
> raise TypeError(f'address type of {address!r} unrecognized') |
| 741 |
# ---------------------------------------------------------------------- |
| 742 |
diff Python-3.10.5/Modules/_multiprocessing/semaphore.c Python-3.10.6/Modules/_multiprocessing/semaphore.c |
| 743 |
455,457c455 |
| 744 |
< SemLockObject *self; |
| 745 |
< |
| 746 |
< self = PyObject_New(SemLockObject, type); |
| 747 |
--- |
| 748 |
> SemLockObject *self = (SemLockObject *)type->tp_alloc(type, 0); |
| 749 |
574c572 |
| 750 |
< PyObject_Free(self); |
| 751 |
--- |
| 752 |
> Py_TYPE(self)->tp_free((PyObject*)self); |
| 753 |
diff Python-3.10.5/Lib/multiprocessing/context.py Python-3.10.6/Lib/multiprocessing/context.py |
| 754 |
225a226,229 |
| 755 |
> @staticmethod |
| 756 |
> def _after_fork(): |
| 757 |
> return _default_context.get_context().Process._after_fork() |
| 758 |
> |
| 759 |
285a290,294 |
| 760 |
> @staticmethod |
| 761 |
> def _after_fork(): |
| 762 |
> # process is spawned, nothing to do |
| 763 |
> pass |
| 764 |
> |
| 765 |
328a338,342 |
| 766 |
> @staticmethod |
| 767 |
> def _after_fork(): |
| 768 |
> # process is spawned, nothing to do |
| 769 |
> pass |
| 770 |
> |
| 771 |
diff Python-3.10.5/Lib/multiprocessing/pool.py Python-3.10.6/Lib/multiprocessing/pool.py |
| 772 |
205a206,208 |
| 773 |
> if maxtasksperchild is not None: |
| 774 |
> if not isinstance(maxtasksperchild, int) or maxtasksperchild <= 0: |
| 775 |
> raise ValueError("maxtasksperchild must be a positive int or None") |
| 776 |
diff Python-3.10.5/Lib/multiprocessing/process.py Python-3.10.6/Lib/multiprocessing/process.py |
| 777 |
307,308c307 |
| 778 |
< util._finalizer_registry.clear() |
| 779 |
< util._run_after_forkers() |
| 780 |
--- |
| 781 |
> self._after_fork() |
| 782 |
338a338,344 |
| 783 |
> @staticmethod |
| 784 |
> def _after_fork(): |
| 785 |
> from . import util |
| 786 |
> util._finalizer_registry.clear() |
| 787 |
> util._run_after_forkers() |
| 788 |
> |
| 789 |
> |
| 790 |
diff Python-3.10.5/Lib/multiprocessing/shared_memory.py Python-3.10.6/Lib/multiprocessing/shared_memory.py |
| 791 |
25a26 |
| 792 |
> from . import resource_tracker |
| 793 |
119,120c120 |
| 794 |
< from .resource_tracker import register |
| 795 |
< register(self._name, "shared_memory") |
| 796 |
--- |
| 797 |
> resource_tracker.register(self._name, "shared_memory") |
| 798 |
240d239 |
| 799 |
< from .resource_tracker import unregister |
| 800 |
242c241 |
| 801 |
< unregister(self._name, "shared_memory") |
| 802 |
--- |
| 803 |
> resource_tracker.unregister(self._name, "shared_memory") |
| 804 |
$ diff Python-3.10.5/Lib/test/_test_multiprocessing.py Python-3.10.6/Lib/test/_test_multiprocessing.py |
| 805 |
7a8 |
| 806 |
> import textwrap |
| 807 |
2806a2808,2812 |
| 808 |
> def test_pool_maxtasksperchild_invalid(self): |
| 809 |
> for value in [0, -1, 0.5, "12"]: |
| 810 |
> with self.assertRaises(ValueError): |
| 811 |
> multiprocessing.Pool(3, maxtasksperchild=value) |
| 812 |
> |
| 813 |
3907c3913 |
| 814 |
< names = ['test01_fn', 'test02_fn'] |
| 815 |
--- |
| 816 |
> names = [self._new_shm_name('test03_fn'), self._new_shm_name('test04_fn')] |
| 817 |
5701a5708,5736 |
| 818 |
> class TestNamedResource(unittest.TestCase): |
| 819 |
> def test_global_named_resource_spawn(self): |
| 820 |
> # |
| 821 |
> # gh-90549: Check that global named resources in main module |
| 822 |
> # will not leak by a subprocess, in spawn context. |
| 823 |
> # |
| 824 |
> testfn = os_helper.TESTFN |
| 825 |
> self.addCleanup(os_helper.unlink, testfn) |
| 826 |
> with open(testfn, 'w', encoding='utf-8') as f: |
| 827 |
> f.write(textwrap.dedent('''\ |
| 828 |
> import multiprocessing as mp |
| 829 |
> |
| 830 |
> ctx = mp.get_context('spawn') |
| 831 |
> |
| 832 |
> global_resource = ctx.Semaphore() |
| 833 |
> |
| 834 |
> def submain(): pass |
| 835 |
> |
| 836 |
> if __name__ == '__main__': |
| 837 |
> p = ctx.Process(target=submain) |
| 838 |
> p.start() |
| 839 |
> p.join() |
| 840 |
> ''')) |
| 841 |
> rc, out, err = test.support.script_helper.assert_python_ok(testfn) |
| 842 |
> # on error, err = 'UserWarning: resource_tracker: There appear to |
| 843 |
> # be 1 leaked semaphore objects to clean up at shutdown' |
| 844 |
> self.assertEqual(err, b'') |
| 845 |
> |
| 846 |
> |
| 847 |
5931a5967,5978 |
| 848 |
> |
| 849 |
> |
| 850 |
> @unittest.skipIf(not hasattr(_multiprocessing, 'SemLock'), 'SemLock not available') |
| 851 |
> @unittest.skipIf(sys.platform != "linux", "Linux only") |
| 852 |
> class SemLockTests(unittest.TestCase): |
| 853 |
> |
| 854 |
> def test_semlock_subclass(self): |
| 855 |
> class SemLock(_multiprocessing.SemLock): |
| 856 |
> pass |
| 857 |
> name = f'test_semlock_subclass-{os.getpid()}' |
| 858 |
> s = SemLock(1, 0, 10, name, 0) |
| 859 |
> _multiprocessing.sem_unlink(name) |
| 860 |
# ---------------------------------------------------------------------- |
| 861 |
diff Python-3.10.6/Lib/multiprocessing/resource_tracker.py Python-3.10.8/Lib/multiprocessing/resource_tracker.py |
| 862 |
164c164 |
| 863 |
< if len(name) > 512: |
| 864 |
--- |
| 865 |
> if len(msg) > 512: |
| 866 |
167c167 |
| 867 |
< raise ValueError('name too long') |
| 868 |
--- |
| 869 |
> raise ValueError('msg too long') |
| 870 |
diff Python-3.10.6/Lib/test/_test_multiprocessing.py Python-3.10.8/Lib/test/_test_multiprocessing.py |
| 871 |
5379a5380,5387 |
| 872 |
> def test_too_long_name_resource(self): |
| 873 |
> # gh-96819: Resource names that will make the length of a write to a pipe |
| 874 |
> # greater than PIPE_BUF are not allowed |
| 875 |
> rtype = "shared_memory" |
| 876 |
> too_long_name_resource = "a" * (512 - len(rtype)) |
| 877 |
> with self.assertRaises(ValueError): |
| 878 |
> resource_tracker.register(too_long_name_resource, rtype) |
| 879 |
> |
| 880 |
# ---------------------------------------------------------------------- |
| 881 |
diff Python-3.10.8/Lib/multiprocessing/connection.py Python-3.10.9/Lib/multiprocessing/connection.py |
| 882 |
76,80d75 |
| 883 |
< # Prefer abstract sockets if possible to avoid problems with the address |
| 884 |
< # size. When coding portable applications, some implementations have |
| 885 |
< # sun_path as short as 92 bytes in the sockaddr_un struct. |
| 886 |
< if util.abstract_sockets_supported: |
| 887 |
< return f"\0listener-{os.getpid()}-{next(_mmap_counter)}" |
| 888 |
Common subdirectories: Python-3.10.8/Lib/multiprocessing/dummy and Python-3.10.9/Lib/multiprocessing/dummy |
| 889 |
diff Python-3.10.8/Lib/multiprocessing/shared_memory.py Python-3.10.9/Lib/multiprocessing/shared_memory.py |
| 890 |
176c176,179 |
| 891 |
< size = _winapi.VirtualQuerySize(p_buf) |
| 892 |
--- |
| 893 |
> try: |
| 894 |
> size = _winapi.VirtualQuerySize(p_buf) |
| 895 |
> finally: |
| 896 |
> _winapi.UnmapViewOfFile(p_buf) |
| 897 |
diff Python-3.10.8/Lib/test/_test_multiprocessing.py Python-3.10.9/Lib/test/_test_multiprocessing.py |
| 898 |
5985c5985 |
| 899 |
< s = SemLock(1, 0, 10, name, 0) |
| 900 |
--- |
| 901 |
> s = SemLock(1, 0, 10, name, False) |