| 1 |
cp -rf py3.8/examples . |
| 2 |
cp -rf py3.8/doc . |
| 3 |
cp -f py3.8/index.html . |
| 4 |
cp -rf py3.8/_multiprocess _multiprocess |
| 5 |
cp -rf py3.8/multiprocess multiprocess |
| 6 |
cp -rf py3.8/Modules Modules |
| 7 |
cp Python-3.9.2/Lib/test/mp_*py multiprocess/tests |
| 8 |
cp Python-3.9.2/Lib/test/_test_multiprocessing.py multiprocess/tests/__init__.py |
| 9 |
|
| 10 |
# ---------------------------------------------------------------------- |
| 11 |
diff Python-3.8.1/Modules/_multiprocessing/multiprocessing.h Python-3.9.0a2/Modules/_multiprocessing/multiprocessing.h |
| 12 |
30,37d29 |
| 13 |
< # define HANDLE int |
| 14 |
< # define SOCKET int |
| 15 |
< # define BOOL int |
| 16 |
< # define UINT32 uint32_t |
| 17 |
< # define INT32 int32_t |
| 18 |
< # define TRUE 1 |
| 19 |
< # define FALSE 0 |
| 20 |
< # define INVALID_HANDLE_VALUE (-1) |
| 21 |
75,76d66 |
| 22 |
< # define F_DWORD "k" |
| 23 |
< # define T_DWORD T_ULONG |
| 24 |
# ---------------------------------------------------------------------- |
| 25 |
diff Python-3.8.1/Lib/multiprocessing/managers.py Python-3.9.0a2/Lib/multiprocessing/managers.py |
| 26 |
251c251 |
| 27 |
< except KeyError as second_ke: |
| 28 |
--- |
| 29 |
> except KeyError: |
| 30 |
299c299 |
| 31 |
< except Exception as e: |
| 32 |
--- |
| 33 |
> except Exception: |
| 34 |
363c363 |
| 35 |
< def create(*args, **kwds): |
| 36 |
--- |
| 37 |
> def create(self, c, typeid, /, *args, **kwds): |
| 38 |
367,392d366 |
| 39 |
< if len(args) >= 3: |
| 40 |
< self, c, typeid, *args = args |
| 41 |
< elif not args: |
| 42 |
< raise TypeError("descriptor 'create' of 'Server' object " |
| 43 |
< "needs an argument") |
| 44 |
< else: |
| 45 |
< if 'typeid' not in kwds: |
| 46 |
< raise TypeError('create expected at least 2 positional ' |
| 47 |
< 'arguments, got %d' % (len(args)-1)) |
| 48 |
< typeid = kwds.pop('typeid') |
| 49 |
< if len(args) >= 2: |
| 50 |
< self, c, *args = args |
| 51 |
< import warnings |
| 52 |
< warnings.warn("Passing 'typeid' as keyword argument is deprecated", |
| 53 |
< DeprecationWarning, stacklevel=2) |
| 54 |
< else: |
| 55 |
< if 'c' not in kwds: |
| 56 |
< raise TypeError('create expected at least 2 positional ' |
| 57 |
< 'arguments, got %d' % (len(args)-1)) |
| 58 |
< c = kwds.pop('c') |
| 59 |
< self, *args = args |
| 60 |
< import warnings |
| 61 |
< warnings.warn("Passing 'c' as keyword argument is deprecated", |
| 62 |
< DeprecationWarning, stacklevel=2) |
| 63 |
< args = tuple(args) |
| 64 |
< |
| 65 |
424d397 |
| 66 |
< create.__text_signature__ = '($self, c, typeid, /, *args, **kwds)' |
| 67 |
1296c1269 |
| 68 |
< def create(*args, **kwargs): |
| 69 |
--- |
| 70 |
> def create(self, c, typeid, /, *args, **kwargs): |
| 71 |
1302,1311d1274 |
| 72 |
< if len(args) >= 3: |
| 73 |
< typeod = args[2] |
| 74 |
< elif 'typeid' in kwargs: |
| 75 |
< typeid = kwargs['typeid'] |
| 76 |
< elif not args: |
| 77 |
< raise TypeError("descriptor 'create' of 'SharedMemoryServer' " |
| 78 |
< "object needs an argument") |
| 79 |
< else: |
| 80 |
< raise TypeError('create expected at least 2 positional ' |
| 81 |
< 'arguments, got %d' % (len(args)-1)) |
| 82 |
1314,1315c1277 |
| 83 |
< return Server.create(*args, **kwargs) |
| 84 |
< create.__text_signature__ = '($self, c, typeid, /, *args, **kwargs)' |
| 85 |
--- |
| 86 |
> return Server.create(self, c, typeid, *args, **kwargs) |
| 87 |
diff Python-3.8.1/Lib/multiprocessing/popen_fork.py Python-3.9.0a2/Lib/multiprocessing/popen_fork.py |
| 88 |
28c28 |
| 89 |
< except OSError as e: |
| 90 |
--- |
| 91 |
> except OSError: |
| 92 |
diff Python-3.8.1/Lib/multiprocessing/util.py Python-3.9.0a2/Lib/multiprocessing/util.py |
| 93 |
432c432 |
| 94 |
< False, False, None) |
| 95 |
--- |
| 96 |
> False, False, None, None, None, -1, None) |
| 97 |
# ---------------------------------------------------------------------- |
| 98 |
diff Python-3.9.0a2/Modules/_multiprocessing/posixshmem.c Python-3.9.0b1/Modules/_multiprocessing/posixshmem.c |
| 99 |
8d7 |
| 100 |
< #include "structmember.h" |
| 101 |
diff Python-3.9.0a2/Modules/_multiprocessing/semaphore.c Python-3.9.0b1/Modules/_multiprocessing/semaphore.c |
| 102 |
271d270 |
| 103 |
< double timeout; |
| 104 |
274,275d272 |
| 105 |
< struct timeval now; |
| 106 |
< long sec, nsec; |
| 107 |
288,290c285,288 |
| 108 |
< if (timeout_obj != Py_None) { |
| 109 |
< timeout = PyFloat_AsDouble(timeout_obj); |
| 110 |
< if (PyErr_Occurred()) |
| 111 |
--- |
| 112 |
> int use_deadline = (timeout_obj != Py_None); |
| 113 |
> if (use_deadline) { |
| 114 |
> double timeout = PyFloat_AsDouble(timeout_obj); |
| 115 |
> if (PyErr_Occurred()) { |
| 116 |
292c290,291 |
| 117 |
< if (timeout < 0.0) |
| 118 |
--- |
| 119 |
> } |
| 120 |
> if (timeout < 0.0) { |
| 121 |
293a293 |
| 122 |
> } |
| 123 |
294a295 |
| 124 |
> struct timeval now; |
| 125 |
299,300c300,301 |
| 126 |
< sec = (long) timeout; |
| 127 |
< nsec = (long) (1e9 * (timeout - sec) + 0.5); |
| 128 |
--- |
| 129 |
> long sec = (long) timeout; |
| 130 |
> long nsec = (long) (1e9 * (timeout - sec) + 0.5); |
| 131 |
318c319 |
| 132 |
< if (timeout_obj == Py_None) { |
| 133 |
--- |
| 134 |
> if (!use_deadline) { |
| 135 |
diff Python-3.9.0a2/Lib/multiprocessing/connection.py Python-3.9.0b1/Lib/multiprocessing/connection.py |
| 136 |
75a76,80 |
| 137 |
> # Prefer abstract sockets if possible to avoid problems with the address |
| 138 |
> # size. When coding portable applications, some implementations have |
| 139 |
> # sun_path as short as 92 bytes in the sockaddr_un struct. |
| 140 |
> if util.abstract_sockets_supported: |
| 141 |
> return f"\0listener-{os.getpid()}-{next(_mmap_counter)}" |
| 142 |
105c110 |
| 143 |
< elif type(address) is str: |
| 144 |
--- |
| 145 |
> elif type(address) is str or util.is_abstract_socket_namespace(address): |
| 146 |
600c605,606 |
| 147 |
< if family == 'AF_UNIX': |
| 148 |
--- |
| 149 |
> if family == 'AF_UNIX' and not util.is_abstract_socket_namespace(address): |
| 150 |
> # Linux abstract socket namespaces do not need to be explicitly unlinked |
| 151 |
diff Python-3.9.0a2/Lib/multiprocessing/forkserver.py Python-3.9.0b1/Lib/multiprocessing/forkserver.py |
| 152 |
58c58,59 |
| 153 |
< os.unlink(self._forkserver_address) |
| 154 |
--- |
| 155 |
> if not util.is_abstract_socket_namespace(self._forkserver_address): |
| 156 |
> os.unlink(self._forkserver_address) |
| 157 |
138c139,140 |
| 158 |
< os.chmod(address, 0o600) |
| 159 |
--- |
| 160 |
> if not util.is_abstract_socket_namespace(address): |
| 161 |
> os.chmod(address, 0o600) |
| 162 |
238,245c240,241 |
| 163 |
< if os.WIFSIGNALED(sts): |
| 164 |
< returncode = -os.WTERMSIG(sts) |
| 165 |
< else: |
| 166 |
< if not os.WIFEXITED(sts): |
| 167 |
< raise AssertionError( |
| 168 |
< "Child {0:n} status is {1:n}".format( |
| 169 |
< pid,sts)) |
| 170 |
< returncode = os.WEXITSTATUS(sts) |
| 171 |
--- |
| 172 |
> returncode = os.waitstatus_to_exitcode(sts) |
| 173 |
> |
| 174 |
diff Python-3.9.0a2/Lib/multiprocessing/managers.py Python-3.9.0b1/Lib/multiprocessing/managers.py |
| 175 |
23a24 |
| 176 |
> import types |
| 177 |
62c63 |
| 178 |
< Type to uniquely indentify a shared object |
| 179 |
--- |
| 180 |
> Type to uniquely identify a shared object |
| 181 |
797c798 |
| 182 |
< Try to call a method of the referrent and return a copy of the result |
| 183 |
--- |
| 184 |
> Try to call a method of the referent and return a copy of the result |
| 185 |
1131a1133,1134 |
| 186 |
> __class_getitem__ = classmethod(types.GenericAlias) |
| 187 |
> |
| 188 |
1264a1268,1271 |
| 189 |
> address = self.address |
| 190 |
> # The address of Linux abstract namespaces can be bytes |
| 191 |
> if isinstance(address, bytes): |
| 192 |
> address = os.fsdecode(address) |
| 193 |
1266c1273 |
| 194 |
< _SharedMemoryTracker(f"shmm_{self.address}_{getpid()}") |
| 195 |
--- |
| 196 |
> _SharedMemoryTracker(f"shm_{address}_{getpid()}") |
| 197 |
diff Python-3.9.0a2/Lib/multiprocessing/pool.py Python-3.9.0b1/Lib/multiprocessing/pool.py |
| 198 |
22a23 |
| 199 |
> import types |
| 200 |
24d24 |
| 201 |
< from queue import Empty |
| 202 |
654,655d653 |
| 203 |
< self._worker_handler._state = TERMINATE |
| 204 |
< self._change_notifier.put(None) |
| 205 |
684a683,685 |
| 206 |
> # Notify that the worker_handler state has been changed so the |
| 207 |
> # _handle_workers loop can be unblocked (and exited) in order to |
| 208 |
> # send the finalization sentinel all the workers. |
| 209 |
685a687,688 |
| 210 |
> change_notifier.put(None) |
| 211 |
> |
| 212 |
779a783,784 |
| 213 |
> __class_getitem__ = classmethod(types.GenericAlias) |
| 214 |
> |
| 215 |
diff Python-3.9.0a2/Lib/multiprocessing/popen_fork.py Python-3.9.0b1/Lib/multiprocessing/popen_fork.py |
| 216 |
33,37c33 |
| 217 |
< if os.WIFSIGNALED(sts): |
| 218 |
< self.returncode = -os.WTERMSIG(sts) |
| 219 |
< else: |
| 220 |
< assert os.WIFEXITED(sts), "Status is {:n}".format(sts) |
| 221 |
< self.returncode = os.WEXITSTATUS(sts) |
| 222 |
--- |
| 223 |
> self.returncode = os.waitstatus_to_exitcode(sts) |
| 224 |
diff Python-3.9.0a2/Lib/multiprocessing/process.py Python-3.9.0b1/Lib/multiprocessing/process.py |
| 225 |
320,323c320,323 |
| 226 |
< if not e.args: |
| 227 |
< exitcode = 1 |
| 228 |
< elif isinstance(e.args[0], int): |
| 229 |
< exitcode = e.args[0] |
| 230 |
--- |
| 231 |
> if e.code is None: |
| 232 |
> exitcode = 0 |
| 233 |
> elif isinstance(e.code, int): |
| 234 |
> exitcode = e.code |
| 235 |
325c325 |
| 236 |
< sys.stderr.write(str(e.args[0]) + '\n') |
| 237 |
--- |
| 238 |
> sys.stderr.write(str(e.code) + '\n') |
| 239 |
diff Python-3.9.0a2/Lib/multiprocessing/queues.py Python-3.9.0b1/Lib/multiprocessing/queues.py |
| 240 |
16a17 |
| 241 |
> import types |
| 242 |
51,52c52 |
| 243 |
< |
| 244 |
< self._after_fork() |
| 245 |
--- |
| 246 |
> self._reset() |
| 247 |
65c65 |
| 248 |
< self._after_fork() |
| 249 |
--- |
| 250 |
> self._reset() |
| 251 |
69c69,75 |
| 252 |
< self._notempty = threading.Condition(threading.Lock()) |
| 253 |
--- |
| 254 |
> self._reset(after_fork=True) |
| 255 |
> |
| 256 |
> def _reset(self, after_fork=False): |
| 257 |
> if after_fork: |
| 258 |
> self._notempty._at_fork_reinit() |
| 259 |
> else: |
| 260 |
> self._notempty = threading.Condition(threading.Lock()) |
| 261 |
342a349,352 |
| 262 |
> def close(self): |
| 263 |
> self._reader.close() |
| 264 |
> self._writer.close() |
| 265 |
> |
| 266 |
368a379,380 |
| 267 |
> |
| 268 |
> __class_getitem__ = classmethod(types.GenericAlias) |
| 269 |
diff Python-3.9.0a2/Lib/multiprocessing/resource_sharer.py Python-3.9.0b1/Lib/multiprocessing/resource_sharer.py |
| 270 |
66d65 |
| 271 |
< self._old_locks = [] |
| 272 |
116,119c115 |
| 273 |
< # If self._lock was locked at the time of the fork, it may be broken |
| 274 |
< # -- see issue 6721. Replace it without letting it be gc'ed. |
| 275 |
< self._old_locks.append(self._lock) |
| 276 |
< self._lock = threading.Lock() |
| 277 |
--- |
| 278 |
> self._lock._at_fork_reinit() |
| 279 |
diff Python-3.9.0a2/Lib/multiprocessing/shared_memory.py Python-3.9.0b1/Lib/multiprocessing/shared_memory.py |
| 280 |
16a17 |
| 281 |
> import types |
| 282 |
253a255,263 |
| 283 |
> # The shared memory area is organized as follows: |
| 284 |
> # - 8 bytes: number of items (N) as a 64-bit integer |
| 285 |
> # - (N + 1) * 8 bytes: offsets of each element from the start of the |
| 286 |
> # data area |
| 287 |
> # - K bytes: the data area storing item values (with encoding and size |
| 288 |
> # depending on their respective types) |
| 289 |
> # - N * 8 bytes: `struct` format string for each element |
| 290 |
> # - N bytes: index into _back_transforms_mapping for each element |
| 291 |
> # (for reconstructing the corresponding Python value) |
| 292 |
285c295,296 |
| 293 |
< if sequence is not None: |
| 294 |
--- |
| 295 |
> if name is None or sequence is not None: |
| 296 |
> sequence = sequence or () |
| 297 |
296,299c307,314 |
| 298 |
< self._allocated_bytes = tuple( |
| 299 |
< self._alignment if fmt[-1] != "s" else int(fmt[:-1]) |
| 300 |
< for fmt in _formats |
| 301 |
< ) |
| 302 |
--- |
| 303 |
> offset = 0 |
| 304 |
> # The offsets of each list element into the shared memory's |
| 305 |
> # data area (0 meaning the start of the data area, not the start |
| 306 |
> # of the shared memory area). |
| 307 |
> self._allocated_offsets = [0] |
| 308 |
> for fmt in _formats: |
| 309 |
> offset += self._alignment if fmt[-1] != "s" else int(fmt[:-1]) |
| 310 |
> self._allocated_offsets.append(offset) |
| 311 |
309a325 |
| 312 |
> self.shm = SharedMemory(name, create=True, size=requested_size) |
| 313 |
311,313d326 |
| 314 |
< requested_size = 8 # Some platforms require > 0. |
| 315 |
< |
| 316 |
< if name is not None and sequence is None: |
| 317 |
315,316d327 |
| 318 |
< else: |
| 319 |
< self.shm = SharedMemory(name, create=True, size=requested_size) |
| 320 |
325c336 |
| 321 |
< *(self._allocated_bytes) |
| 322 |
--- |
| 323 |
> *(self._allocated_offsets) |
| 324 |
348,351c359,364 |
| 325 |
< self._allocated_bytes = struct.unpack_from( |
| 326 |
< self._format_size_metainfo, |
| 327 |
< self.shm.buf, |
| 328 |
< 1 * 8 |
| 329 |
--- |
| 330 |
> self._allocated_offsets = list( |
| 331 |
> struct.unpack_from( |
| 332 |
> self._format_size_metainfo, |
| 333 |
> self.shm.buf, |
| 334 |
> 1 * 8 |
| 335 |
> ) |
| 336 |
373d385 |
| 337 |
< position = position if position >= 0 else position + self._list_len |
| 338 |
390d401 |
| 339 |
< position = position if position >= 0 else position + self._list_len |
| 340 |
409a421 |
| 341 |
> position = position if position >= 0 else position + self._list_len |
| 342 |
411,412c423 |
| 343 |
< offset = self._offset_data_start \ |
| 344 |
< + sum(self._allocated_bytes[:position]) |
| 345 |
--- |
| 346 |
> offset = self._offset_data_start + self._allocated_offsets[position] |
| 347 |
426a438 |
| 348 |
> position = position if position >= 0 else position + self._list_len |
| 349 |
428,429c440,441 |
| 350 |
< offset = self._offset_data_start \ |
| 351 |
< + sum(self._allocated_bytes[:position]) |
| 352 |
--- |
| 353 |
> item_offset = self._allocated_offsets[position] |
| 354 |
> offset = self._offset_data_start + item_offset |
| 355 |
435a448 |
| 356 |
> encoded_value = value |
| 357 |
437,438c450,455 |
| 358 |
< if len(value) > self._allocated_bytes[position]: |
| 359 |
< raise ValueError("exceeds available storage for existing str") |
| 360 |
--- |
| 361 |
> allocated_length = self._allocated_offsets[position + 1] - item_offset |
| 362 |
> |
| 363 |
> encoded_value = (value.encode(_encoding) |
| 364 |
> if isinstance(value, str) else value) |
| 365 |
> if len(encoded_value) > allocated_length: |
| 366 |
> raise ValueError("bytes/str item exceeds available storage") |
| 367 |
443c460 |
| 368 |
< self._allocated_bytes[position], |
| 369 |
--- |
| 370 |
> allocated_length, |
| 371 |
451,452c468 |
| 372 |
< value = value.encode(_encoding) if isinstance(value, str) else value |
| 373 |
< struct.pack_into(new_format, self.shm.buf, offset, value) |
| 374 |
--- |
| 375 |
> struct.pack_into(new_format, self.shm.buf, offset, encoded_value) |
| 376 |
465c481 |
| 377 |
< "The struct packing format used by all currently stored values." |
| 378 |
--- |
| 379 |
> "The struct packing format used by all currently stored items." |
| 380 |
472,473c488,489 |
| 381 |
< "The struct packing format used for metainfo on storage sizes." |
| 382 |
< return f"{self._list_len}q" |
| 383 |
--- |
| 384 |
> "The struct packing format used for the items' storage offsets." |
| 385 |
> return "q" * (self._list_len + 1) |
| 386 |
477c493 |
| 387 |
< "The struct packing format used for the values' packing formats." |
| 388 |
--- |
| 389 |
> "The struct packing format used for the items' packing formats." |
| 390 |
482c498 |
| 391 |
< "The struct packing format used for the values' back transforms." |
| 392 |
--- |
| 393 |
> "The struct packing format used for the items' back transforms." |
| 394 |
487c503,505 |
| 395 |
< return (self._list_len + 1) * 8 # 8 bytes per "q" |
| 396 |
--- |
| 397 |
> # - 8 bytes for the list length |
| 398 |
> # - (N + 1) * 8 bytes for the element offsets |
| 399 |
> return (self._list_len + 2) * 8 |
| 400 |
491c509 |
| 401 |
< return self._offset_data_start + sum(self._allocated_bytes) |
| 402 |
--- |
| 403 |
> return self._offset_data_start + self._allocated_offsets[-1] |
| 404 |
510a529,530 |
| 405 |
> |
| 406 |
> __class_getitem__ = classmethod(types.GenericAlias) |
| 407 |
diff Python-3.9.0a2/Lib/multiprocessing/spawn.py Python-3.9.0b1/Lib/multiprocessing/spawn.py |
| 408 |
39c39 |
| 409 |
< _python_exe = sys._base_executable |
| 410 |
--- |
| 411 |
> _python_exe = sys.executable |
| 412 |
diff Python-3.9.0a2/Lib/multiprocessing/util.py Python-3.9.0b1/Lib/multiprocessing/util.py |
| 413 |
104a105,127 |
| 414 |
> |
| 415 |
> # Abstract socket support |
| 416 |
> |
| 417 |
> def _platform_supports_abstract_sockets(): |
| 418 |
> if sys.platform == "linux": |
| 419 |
> return True |
| 420 |
> if hasattr(sys, 'getandroidapilevel'): |
| 421 |
> return True |
| 422 |
> return False |
| 423 |
> |
| 424 |
> |
| 425 |
> def is_abstract_socket_namespace(address): |
| 426 |
> if not address: |
| 427 |
> return False |
| 428 |
> if isinstance(address, bytes): |
| 429 |
> return address[0] == 0 |
| 430 |
> elif isinstance(address, str): |
| 431 |
> return address[0] == "\0" |
| 432 |
> raise TypeError('address type of {address!r} unrecognized') |
| 433 |
> |
| 434 |
> |
| 435 |
> abstract_sockets_supported = _platform_supports_abstract_sockets() |
| 436 |
> |
| 437 |
347,350d369 |
| 438 |
< self._reset() |
| 439 |
< register_after_fork(self, ForkAwareThreadLock._reset) |
| 440 |
< |
| 441 |
< def _reset(self): |
| 442 |
353a373,376 |
| 443 |
> register_after_fork(self, ForkAwareThreadLock._at_fork_reinit) |
| 444 |
> |
| 445 |
> def _at_fork_reinit(self): |
| 446 |
> self._lock._at_fork_reinit() |
| 447 |
# ---------------------------------------------------------------------- |
| 448 |
diff Python-3.9.0b1/Lib/multiprocessing/context.py Python-3.9.0/Lib/multiprocessing/context.py |
| 449 |
259a260 |
| 450 |
> methods = ['spawn', 'fork'] if sys.platform == 'darwin' else ['fork', 'spawn'] |
| 451 |
261,263c262,264 |
| 452 |
< return ['fork', 'spawn', 'forkserver'] |
| 453 |
< else: |
| 454 |
< return ['fork', 'spawn'] |
| 455 |
--- |
| 456 |
> methods.append('forkserver') |
| 457 |
> return methods |
| 458 |
> |
| 459 |
Common subdirectories: Python-3.9.0b1/Lib/multiprocessing/dummy and Python-3.9.0/Lib/multiprocessing/dummy |
| 460 |
diff Python-3.9.0b1/Lib/multiprocessing/shared_memory.py Python-3.9.0/Lib/multiprocessing/shared_memory.py |
| 461 |
78a79,80 |
| 462 |
> if size == 0: |
| 463 |
> raise ValueError("'size' must be a positive number different from zero") |
| 464 |
diff Python-3.9.0b1/Lib/multiprocessing/synchronize.py Python-3.9.0/Lib/multiprocessing/synchronize.py |
| 465 |
273c273 |
| 466 |
< False), ('notify: Should not have been able to acquire' |
| 467 |
--- |
| 468 |
> False), ('notify: Should not have been able to acquire ' |
| 469 |
# ---------------------------------------------------------------------- |
| 470 |
diff Python-3.9.2/Lib/test/_test_multiprocessing.py multiprocess/tests/__init__.py |
| 471 |
23c23 |
| 472 |
< import pickle |
| 473 |
--- |
| 474 |
> import pickle #XXX: use dill? |
| 475 |
36c36 |
| 476 |
< support.skip_if_broken_multiprocessing_synchronize() |
| 477 |
--- |
| 478 |
> test.support.import_module('multiprocess.synchronize') |
| 479 |
39,44c39,45 |
| 480 |
< import multiprocessing.connection |
| 481 |
< import multiprocessing.dummy |
| 482 |
< import multiprocessing.heap |
| 483 |
< import multiprocessing.managers |
| 484 |
< import multiprocessing.pool |
| 485 |
< import multiprocessing.queues |
| 486 |
--- |
| 487 |
> import multiprocess as multiprocessing |
| 488 |
> import multiprocess.connection |
| 489 |
> import multiprocess.dummy |
| 490 |
> import multiprocess.heap |
| 491 |
> import multiprocess.managers |
| 492 |
> import multiprocess.pool |
| 493 |
> import multiprocess.queues |
| 494 |
46c47 |
| 495 |
< from multiprocessing import util |
| 496 |
--- |
| 497 |
> from multiprocess import util |
| 498 |
49c50 |
| 499 |
< from multiprocessing import reduction |
| 500 |
--- |
| 501 |
> from multiprocess import reduction |
| 502 |
55c56 |
| 503 |
< from multiprocessing.sharedctypes import Value, copy |
| 504 |
--- |
| 505 |
> from multiprocess.sharedctypes import Value, copy |
| 506 |
61c62 |
| 507 |
< from multiprocessing import shared_memory |
| 508 |
--- |
| 509 |
> from multiprocess import shared_memory |
| 510 |
89c90 |
| 511 |
< from multiprocessing import resource_tracker |
| 512 |
--- |
| 513 |
> from multiprocess import resource_tracker |
| 514 |
117c118 |
| 515 |
< from multiprocessing.connection import wait |
| 516 |
--- |
| 517 |
> from multiprocess.connection import wait |
| 518 |
130c131 |
| 519 |
< PRELOAD = ['__main__', 'test.test_multiprocessing_forkserver'] |
| 520 |
--- |
| 521 |
> PRELOAD = ['__main__', 'test_multiprocessing_forkserver'] |
| 522 |
169c170 |
| 523 |
< t = time.monotonic() |
| 524 |
--- |
| 525 |
> t = getattr(time,'monotonic',time.time)() |
| 526 |
173c174 |
| 527 |
< self.elapsed = time.monotonic() - t |
| 528 |
--- |
| 529 |
> self.elapsed = getattr(time,'monotonic',time.time)() - t |
| 530 |
285c286 |
| 531 |
< from multiprocessing.process import parent_process |
| 532 |
--- |
| 533 |
> from multiprocess.process import parent_process |
| 534 |
288c289 |
| 535 |
< def test_parent_process(self): |
| 536 |
--- |
| 537 |
> def _test_parent_process(self): |
| 538 |
321c322 |
| 539 |
< from multiprocessing.process import parent_process |
| 540 |
--- |
| 541 |
> from multiprocess.process import parent_process |
| 542 |
488a490 |
| 543 |
> @unittest.skipIf(True, "fails with is_dill(obj, child=True)") |
| 544 |
740c742 |
| 545 |
< from multiprocessing.forkserver import _forkserver |
| 546 |
--- |
| 547 |
> from multiprocess.forkserver import _forkserver |
| 548 |
829c831 |
| 549 |
< self.assertIn("test_multiprocessing.py", err) |
| 550 |
--- |
| 551 |
> self.assertIn("__init__.py", err) |
| 552 |
1119c1121 |
| 553 |
< import multiprocessing |
| 554 |
--- |
| 555 |
> import multiprocess as multiprocessing |
| 556 |
1137c1139 |
| 557 |
< start = time.monotonic() |
| 558 |
--- |
| 559 |
> start = getattr(time,'monotonic',time.time)() |
| 560 |
1139c1141 |
| 561 |
< delta = time.monotonic() - start |
| 562 |
--- |
| 563 |
> delta = getattr(time,'monotonic',time.time)() - start |
| 564 |
1541c1543 |
| 565 |
< dt = time.monotonic() |
| 566 |
--- |
| 567 |
> dt = getattr(time,'monotonic',time.time)() |
| 568 |
1543c1545 |
| 569 |
< dt = time.monotonic() - dt |
| 570 |
--- |
| 571 |
> dt = getattr(time,'monotonic',time.time)() - dt |
| 572 |
2012c2014 |
| 573 |
< self.skipTest("requires multiprocessing.sharedctypes") |
| 574 |
--- |
| 575 |
> self.skipTest("requires multiprocess.sharedctypes") |
| 576 |
2578a2581 |
| 577 |
> @unittest.skipIf(True, "fails with is_dill(obj, child=True)") |
| 578 |
2620a2624 |
| 579 |
> @unittest.skipIf(True, "fails with is_dill(obj, child=True)") |
| 580 |
2634c2638 |
| 581 |
< t_start = time.monotonic() |
| 582 |
--- |
| 583 |
> t_start = getattr(time,'monotonic',time.time)() |
| 584 |
2646c2650 |
| 585 |
< self.assertGreater(time.monotonic() - t_start, 0.9) |
| 586 |
--- |
| 587 |
> self.assertGreater(getattr(time,'monotonic',time.time)() - t_start, 0.9) |
| 588 |
2718,2719c2722,2723 |
| 589 |
< def test_unpickleable_result(self): |
| 590 |
< from multiprocessing.pool import MaybeEncodingError |
| 591 |
--- |
| 592 |
> def _test_unpickleable_result(self): |
| 593 |
> from multiprocess.pool import MaybeEncodingError |
| 594 |
2807c2811 |
| 595 |
< from multiprocessing.managers import BaseManager, BaseProxy, RemoteError |
| 596 |
--- |
| 597 |
> from multiprocess.managers import BaseManager, BaseProxy, RemoteError |
| 598 |
3450c3454 |
| 599 |
< from multiprocessing import resource_sharer |
| 600 |
--- |
| 601 |
> from multiprocess import resource_sharer |
| 602 |
3695c3699 |
| 603 |
< self.skipTest("requires multiprocessing.sharedctypes") |
| 604 |
--- |
| 605 |
> self.skipTest("requires multiprocess.sharedctypes") |
| 606 |
3745c3749 |
| 607 |
< @unittest.skipUnless(HAS_SHMEM, "requires multiprocessing.shared_memory") |
| 608 |
--- |
| 609 |
> @unittest.skipUnless(HAS_SHMEM, "requires multiprocess.shared_memory") |
| 610 |
4123c4127 |
| 611 |
< deadline = time.monotonic() + support.LONG_TIMEOUT |
| 612 |
--- |
| 613 |
> deadline = getattr(time,'monotonic',time.time)() + support.LONG_TIMEOUT |
| 614 |
4125c4129 |
| 615 |
< while time.monotonic() < deadline: |
| 616 |
--- |
| 617 |
> while getattr(time,'monotonic',time.time)() < deadline: |
| 618 |
4277,4279c4281,4283 |
| 619 |
< modules = ['multiprocessing.' + m for m in modules] |
| 620 |
< modules.remove('multiprocessing.__init__') |
| 621 |
< modules.append('multiprocessing') |
| 622 |
--- |
| 623 |
> modules = ['multiprocess.' + m for m in modules] |
| 624 |
> modules.remove('multiprocess.__init__') |
| 625 |
> modules.append('multiprocess') |
| 626 |
4285,4287c4289,4291 |
| 627 |
< modules.remove('multiprocessing.popen_fork') |
| 628 |
< modules.remove('multiprocessing.popen_forkserver') |
| 629 |
< modules.remove('multiprocessing.popen_spawn_posix') |
| 630 |
--- |
| 631 |
> modules.remove('multiprocess.popen_fork') |
| 632 |
> modules.remove('multiprocess.popen_forkserver') |
| 633 |
> modules.remove('multiprocess.popen_spawn_posix') |
| 634 |
4289c4293 |
| 635 |
< modules.remove('multiprocessing.popen_spawn_win32') |
| 636 |
--- |
| 637 |
> modules.remove('multiprocess.popen_spawn_win32') |
| 638 |
4291c4295 |
| 639 |
< modules.remove('multiprocessing.popen_forkserver') |
| 640 |
--- |
| 641 |
> modules.remove('multiprocess.popen_forkserver') |
| 642 |
4295c4299 |
| 643 |
< modules.remove('multiprocessing.sharedctypes') |
| 644 |
--- |
| 645 |
> modules.remove('multiprocess.sharedctypes') |
| 646 |
4577c4581 |
| 647 |
< from multiprocessing.connection import wait |
| 648 |
--- |
| 649 |
> from multiprocess.connection import wait |
| 650 |
4617c4621 |
| 651 |
< from multiprocessing.connection import wait |
| 652 |
--- |
| 653 |
> from multiprocess.connection import wait |
| 654 |
4658c4662 |
| 655 |
< from multiprocessing.connection import wait |
| 656 |
--- |
| 657 |
> from multiprocess.connection import wait |
| 658 |
4663c4667 |
| 659 |
< start = time.monotonic() |
| 660 |
--- |
| 661 |
> start = getattr(time,'monotonic',time.time)() |
| 662 |
4665c4669 |
| 663 |
< delta = time.monotonic() - start |
| 664 |
--- |
| 665 |
> delta = getattr(time,'monotonic',time.time)() - start |
| 666 |
4673c4677 |
| 667 |
< start = time.monotonic() |
| 668 |
--- |
| 669 |
> start = getattr(time,'monotonic',time.time)() |
| 670 |
4675c4679 |
| 671 |
< delta = time.monotonic() - start |
| 672 |
--- |
| 673 |
> delta = getattr(time,'monotonic',time.time)() - start |
| 674 |
4686c4690 |
| 675 |
< from multiprocessing.connection import wait |
| 676 |
--- |
| 677 |
> from multiprocess.connection import wait |
| 678 |
4699c4703 |
| 679 |
< start = time.monotonic() |
| 680 |
--- |
| 681 |
> start = getattr(time,'monotonic',time.time)() |
| 682 |
4701c4705 |
| 683 |
< delta = time.monotonic() - start |
| 684 |
--- |
| 685 |
> delta = getattr(time,'monotonic',time.time)() - start |
| 686 |
4709c4713 |
| 687 |
< start = time.monotonic() |
| 688 |
--- |
| 689 |
> start = getattr(time,'monotonic',time.time)() |
| 690 |
4711c4715 |
| 691 |
< delta = time.monotonic() - start |
| 692 |
--- |
| 693 |
> delta = getattr(time,'monotonic',time.time)() - start |
| 694 |
4718c4722 |
| 695 |
< start = time.monotonic() |
| 696 |
--- |
| 697 |
> start = getattr(time,'monotonic',time.time)() |
| 698 |
4720c4724 |
| 699 |
< delta = time.monotonic() - start |
| 700 |
--- |
| 701 |
> delta = getattr(time,'monotonic',time.time)() - start |
| 702 |
4729c4733 |
| 703 |
< from multiprocessing.connection import wait |
| 704 |
--- |
| 705 |
> from multiprocess.connection import wait |
| 706 |
4731c4735 |
| 707 |
< t = time.monotonic() |
| 708 |
--- |
| 709 |
> t = getattr(time,'monotonic',time.time)() |
| 710 |
4733c4737 |
| 711 |
< t = time.monotonic() - t |
| 712 |
--- |
| 713 |
> t = getattr(time,'monotonic',time.time)() - t |
| 714 |
4777c4781 |
| 715 |
< def test_flags(self): |
| 716 |
--- |
| 717 |
> def _test_flags(self): |
| 718 |
4780c4784 |
| 719 |
< prog = ('from test._test_multiprocessing import TestFlags; ' + |
| 720 |
--- |
| 721 |
> prog = ('from multiprocess.tests import TestFlags; ' + |
| 722 |
5082c5086 |
| 723 |
< def test_resource_tracker(self): |
| 724 |
--- |
| 725 |
> def _test_resource_tracker(self): |
| 726 |
5088,5090c5092,5094 |
| 727 |
< import multiprocessing as mp |
| 728 |
< from multiprocessing import resource_tracker |
| 729 |
< from multiprocessing.shared_memory import SharedMemory |
| 730 |
--- |
| 731 |
> import multiprocess as mp |
| 732 |
> from multiprocess import resource_tracker |
| 733 |
> from multiprocess.shared_memory import SharedMemory |
| 734 |
5134,5135c5138,5139 |
| 735 |
< deadline = time.monotonic() + support.LONG_TIMEOUT |
| 736 |
< while time.monotonic() < deadline: |
| 737 |
--- |
| 738 |
> deadline = getattr(time,'monotonic',time.time)() + support.LONG_TIMEOUT |
| 739 |
> while getattr(time,'monotonic',time.time)() < deadline: |
| 740 |
5159c5163 |
| 741 |
< from multiprocessing.resource_tracker import _resource_tracker |
| 742 |
--- |
| 743 |
> from multiprocess.resource_tracker import _resource_tracker |
| 744 |
5207c5211 |
| 745 |
< from multiprocessing.resource_tracker import _resource_tracker |
| 746 |
--- |
| 747 |
> from multiprocess.resource_tracker import _resource_tracker |
| 748 |
5216c5220 |
| 749 |
< from multiprocessing.resource_tracker import _resource_tracker |
| 750 |
--- |
| 751 |
> from multiprocess.resource_tracker import _resource_tracker |
| 752 |
5375c5379 |
| 753 |
< start_time = time.monotonic() |
| 754 |
--- |
| 755 |
> start_time = getattr(time,'monotonic',time.time)() |
| 756 |
5380c5384 |
| 757 |
< dt = time.monotonic() - start_time |
| 758 |
--- |
| 759 |
> dt = getattr(time,'monotonic',time.time)() - start_time |
| 760 |
5383c5387 |
| 761 |
< support.print_warning(f"multiprocessing.Manager still has " |
| 762 |
--- |
| 763 |
> support.print_warning(f"multiprocess.Manager still has " |
| 764 |
5651c5655 |
| 765 |
< start_time = time.monotonic() |
| 766 |
--- |
| 767 |
> start_time = getattr(time,'monotonic',time.time)() |
| 768 |
5656c5660 |
| 769 |
< dt = time.monotonic() - start_time |
| 770 |
--- |
| 771 |
> dt = getattr(time,'monotonic',time.time)() - start_time |
| 772 |
5659c5663 |
| 773 |
< support.print_warning(f"multiprocessing.Manager still has " |
| 774 |
--- |
| 775 |
> support.print_warning(f"multiprocess.Manager still has " |
| 776 |
# ---------------------------------------------------------------------- |
| 777 |
diff Python-3.9.4/Lib/test/_test_multiprocessing.py Python-3.9.7/Lib/test/_test_multiprocessing.py |
| 778 |
609a610 |
| 779 |
> gc.collect() # For PyPy or other GCs. |
| 780 |
2284a2286,2295 |
| 781 |
> def test_nested_queue(self): |
| 782 |
> a = self.list() # Test queue inside list |
| 783 |
> a.append(self.Queue()) |
| 784 |
> a[0].put(123) |
| 785 |
> self.assertEqual(a[0].get(), 123) |
| 786 |
> b = self.dict() # Test queue inside dict |
| 787 |
> b[0] = self.Queue() |
| 788 |
> b[0].put(456) |
| 789 |
> self.assertEqual(b[0].get(), 456) |
| 790 |
> |
| 791 |
2655a2667 |
| 792 |
> gc.collect() # For PyPy or other GCs. |
| 793 |
4157a4170 |
| 794 |
> gc.collect() # For PyPy or other GCs. |
| 795 |
4168a4182 |
| 796 |
> gc.collect() # For PyPy or other GCs. |
| 797 |
4174a4189 |
| 798 |
> gc.collect() # For PyPy or other GCs. |
| 799 |
# ---------------------------------------------------------------------- |
| 800 |
diff Python-3.9.4/Lib/multiprocessing/managers.py Python-3.9.7/Lib/multiprocessing/managers.py |
| 801 |
11,12c11 |
| 802 |
< __all__ = [ 'BaseManager', 'SyncManager', 'BaseProxy', 'Token', |
| 803 |
< 'SharedMemoryManager' ] |
| 804 |
--- |
| 805 |
> __all__ = [ 'BaseManager', 'SyncManager', 'BaseProxy', 'Token' ] |
| 806 |
38d36 |
| 807 |
< HAS_SHMEM = True |
| 808 |
40a39,41 |
| 809 |
> else: |
| 810 |
> HAS_SHMEM = True |
| 811 |
> __all__.append('SharedMemoryManager') |
| 812 |
962c963 |
| 813 |
< exposed=None, incref=True): |
| 814 |
--- |
| 815 |
> exposed=None, incref=True, manager_owned=False): |
| 816 |
982c983 |
| 817 |
< incref=incref) |
| 818 |
--- |
| 819 |
> incref=incref, manager_owned=manager_owned) |
| 820 |
# ---------------------------------------------------------------------- |
| 821 |
dude@borel>$ diff Python-3.9.7/Lib/test/_test_multiprocessing.py Python-3.9.9/Lib/test/_test_multiprocessing.py |
| 822 |
3771a3772,3778 |
| 823 |
> def _new_shm_name(self, prefix): |
| 824 |
> # Add a PID to the name of a POSIX shared memory object to allow |
| 825 |
> # running multiprocessing tests (test_multiprocessing_fork, |
| 826 |
> # test_multiprocessing_spawn, etc) in parallel. |
| 827 |
> return prefix + str(os.getpid()) |
| 828 |
> |
| 829 |
> @unittest.skipIf(sys.platform == "win32", "test is broken on Windows") |
| 830 |
> @unittest.skipIf(True, "fails with is_dill(obj, child=True)") |
| 831 |
3773c3780,3781 |
| 832 |
< sms = shared_memory.SharedMemory('test01_tsmb', create=True, size=512) |
| 833 |
--- |
| 834 |
> name_tsmb = self._new_shm_name('test01_tsmb') |
| 835 |
> sms = shared_memory.SharedMemory(name_tsmb, create=True, size=512) |
| 836 |
3777c3785 |
| 837 |
< self.assertEqual(sms.name, 'test01_tsmb') |
| 838 |
--- |
| 839 |
> self.assertEqual(sms.name, name_tsmb) |
| 840 |
3786c3794 |
| 841 |
< also_sms = shared_memory.SharedMemory('test01_tsmb') |
| 842 |
--- |
| 843 |
> also_sms = shared_memory.SharedMemory(name_tsmb) |
| 844 |
3791c3799 |
| 845 |
< same_sms = shared_memory.SharedMemory('test01_tsmb', size=20*sms.size) |
| 846 |
--- |
| 847 |
> same_sms = shared_memory.SharedMemory(name_tsmb, size=20*sms.size) |
| 848 |
3809c3817 |
| 849 |
< names = ['test01_fn', 'test02_fn'] |
| 850 |
--- |
| 851 |
> names = [self._new_shm_name('test01_fn'), self._new_shm_name('test02_fn')] |
| 852 |
3830a3839,3844 |
| 853 |
> name_dblunlink = self._new_shm_name('test01_dblunlink') |
| 854 |
> sms_uno = shared_memory.SharedMemory( |
| 855 |
> name_dblunlink, |
| 856 |
> create=True, |
| 857 |
> size=5000 |
| 858 |
> ) |
| 859 |
3832,3837d3845 |
| 860 |
< sms_uno = shared_memory.SharedMemory( |
| 861 |
< 'test01_dblunlink', |
| 862 |
< create=True, |
| 863 |
< size=5000 |
| 864 |
< ) |
| 865 |
< |
| 866 |
3841c3849 |
| 867 |
< sms_duo = shared_memory.SharedMemory('test01_dblunlink') |
| 868 |
--- |
| 869 |
> sms_duo = shared_memory.SharedMemory(name_dblunlink) |
| 870 |
3853c3861 |
| 871 |
< 'test01_tsmb', |
| 872 |
--- |
| 873 |
> name_tsmb, |
| 874 |
3867c3875 |
| 875 |
< ok_if_exists_sms = OptionalAttachSharedMemory('test01_tsmb') |
| 876 |
--- |
| 877 |
> ok_if_exists_sms = OptionalAttachSharedMemory(name_tsmb) |
| 878 |
4055c4063,4064 |
| 879 |
< sl_copy = shared_memory.ShareableList(sl, name='test03_duplicate') |
| 880 |
--- |
| 881 |
> name_duplicate = self._new_shm_name('test03_duplicate') |
| 882 |
> sl_copy = shared_memory.ShareableList(sl, name=name_duplicate) |
| 883 |
4058c4067 |
| 884 |
< self.assertEqual('test03_duplicate', sl_copy.shm.name) |
| 885 |
--- |
| 886 |
> self.assertEqual(name_duplicate, sl_copy.shm.name) |
| 887 |
4148a4158,4164 |
| 888 |
> # Without this line it was raising warnings like: |
| 889 |
> # UserWarning: resource_tracker: |
| 890 |
> # There appear to be 1 leaked shared_memory |
| 891 |
> # objects to clean up at shutdown |
| 892 |
> # See: https://bugs.python.org/issue45209 |
| 893 |
> resource_tracker.unregister(f"/{name}", "shared_memory") |
| 894 |
> |
| 895 |
# ---------------------------------------------------------------------- |
| 896 |
$ diff Python-3.9.10/Lib/test/_test_multiprocessing.py Python-3.9.12/Lib/test/_test_multiprocessing.py |
| 897 |
71a72,77 |
| 898 |
> if support.check_sanitizer(address=True): |
| 899 |
> # bpo-45200: Skip multiprocessing tests if Python is built with ASAN to |
| 900 |
> # work around a libasan race condition: dead lock in pthread_create(). |
| 901 |
> raise unittest.SkipTest("libasan has a pthread_create() dead lock") |
| 902 |
> |
| 903 |
> |
| 904 |
# ---------------------------------------------------------------------- |
| 905 |
diff Python-3.9.12/Lib/multiprocessing/managers.py Python-3.9.13/Lib/multiprocessing/managers.py |
| 906 |
672c672 |
| 907 |
< process.join(timeout=0.1) |
| 908 |
--- |
| 909 |
> process.join(timeout=1.0) |
| 910 |
diff Python-3.9.12/Lib/multiprocessing/queues.py Python-3.9.13/Lib/multiprocessing/queues.py |
| 911 |
142,148c142,145 |
| 912 |
< try: |
| 913 |
< self._reader.close() |
| 914 |
< finally: |
| 915 |
< close = self._close |
| 916 |
< if close: |
| 917 |
< self._close = None |
| 918 |
< close() |
| 919 |
--- |
| 920 |
> close = self._close |
| 921 |
> if close: |
| 922 |
> self._close = None |
| 923 |
> close() |
| 924 |
172,173c169,171 |
| 925 |
< self._wlock, self._writer.close, self._ignore_epipe, |
| 926 |
< self._on_queue_feeder_error, self._sem), |
| 927 |
--- |
| 928 |
> self._wlock, self._reader.close, self._writer.close, |
| 929 |
> self._ignore_epipe, self._on_queue_feeder_error, |
| 930 |
> self._sem), |
| 931 |
214,215c212,213 |
| 932 |
< def _feed(buffer, notempty, send_bytes, writelock, close, ignore_epipe, |
| 933 |
< onerror, queue_sem): |
| 934 |
--- |
| 935 |
> def _feed(buffer, notempty, send_bytes, writelock, reader_close, |
| 936 |
> writer_close, ignore_epipe, onerror, queue_sem): |
| 937 |
241c239,240 |
| 938 |
< close() |
| 939 |
--- |
| 940 |
> reader_close() |
| 941 |
> writer_close() |
| 942 |
diff Python-3.9.12/Lib/multiprocessing/util.py Python-3.9.13/Lib/multiprocessing/util.py |
| 943 |
123c123 |
| 944 |
< raise TypeError('address type of {address!r} unrecognized') |
| 945 |
--- |
| 946 |
> raise TypeError(f'address type of {address!r} unrecognized') |
| 947 |
# ---------------------------------------------------------------------- |
| 948 |
diff Python-3.9.13/Lib/multiprocessing/connection.py Python-3.9.16/Lib/multiprocessing/connection.py |
| 949 |
76,80d75 |
| 950 |
< # Prefer abstract sockets if possible to avoid problems with the address |
| 951 |
< # size. When coding portable applications, some implementations have |
| 952 |
< # sun_path as short as 92 bytes in the sockaddr_un struct. |
| 953 |
< if util.abstract_sockets_supported: |
| 954 |
< return f"\0listener-{os.getpid()}-{next(_mmap_counter)}" |
| 955 |
|