Skip to content

Commit b480c3a

Browse files
authored
Removed Sized and MacSafeQueues (#3945)
These are both unused (since PR #3944) See issue #3929 for more discussion # Changed Behaviour This is removing now-unused code # Fixes Fixes #3929 ## Type of change - Code maintenance/cleanup
1 parent c0a5986 commit b480c3a

File tree

2 files changed

+0
-111
lines changed

2 files changed

+0
-111
lines changed

parsl/multiprocessing.py

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import logging
55
import multiprocessing
66
import multiprocessing.queues
7-
import platform
87
from multiprocessing.context import ForkProcess as ForkProcessType
98
from multiprocessing.context import SpawnProcess as SpawnProcessType
109
from typing import Callable
@@ -21,54 +20,6 @@
2120
SpawnQueue = SpawnContext.Queue
2221

2322

24-
class MacSafeQueue(multiprocessing.queues.Queue):
25-
""" Multiprocessing queues do not have qsize attributes on MacOS.
26-
This is slower but more portable version of the multiprocessing Queue
27-
that adds a explicit counter
28-
29-
Reference : https://github.com/keras-team/autokeras/commit/4ddd568b06b4045ace777bc0fb7bc18573b85a75
30-
"""
31-
32-
def __init__(self, *args, **kwargs):
33-
if 'ctx' not in kwargs:
34-
kwargs['ctx'] = multiprocessing.get_context('spawn')
35-
super().__init__(*args, **kwargs)
36-
self._counter = multiprocessing.Value('i', 0)
37-
38-
def put(self, *args, **kwargs):
39-
# logger.critical("Putting item {}".format(args))
40-
x = super().put(*args, **kwargs)
41-
with self._counter.get_lock():
42-
self._counter.value += 1
43-
return x
44-
45-
def get(self, *args, **kwargs):
46-
x = super().get(*args, **kwargs)
47-
with self._counter.get_lock():
48-
self._counter.value -= 1
49-
# logger.critical("Getting item {}".format(x))
50-
return x
51-
52-
def qsize(self):
53-
return self._counter.value
54-
55-
def empty(self):
56-
return not self._counter.value
57-
58-
59-
# SizedQueue should be constructable using the same calling
60-
# convention as multiprocessing.Queue but that entire signature
61-
# isn't expressible in mypy 0.790
62-
SizedQueue: Callable[..., multiprocessing.Queue]
63-
64-
65-
if platform.system() != 'Darwin':
66-
import multiprocessing
67-
SizedQueue = SpawnQueue
68-
else:
69-
SizedQueue = MacSafeQueue
70-
71-
7223
def join_terminate_close_proc(process: SpawnProcessType, *, timeout: int = 30) -> None:
7324
"""Increasingly aggressively terminate a process.
7425

parsl/tests/test_regression/test_854.py

Lines changed: 0 additions & 62 deletions
This file was deleted.

0 commit comments

Comments
 (0)