summaryrefslogtreecommitdiffstats
path: root/Lib/multiprocessing
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/multiprocessing')
-rw-r--r--Lib/multiprocessing/managers.py47
1 files changed, 43 insertions, 4 deletions
diff --git a/Lib/multiprocessing/managers.py b/Lib/multiprocessing/managers.py
index 7973012..80c3ddb 100644
--- a/Lib/multiprocessing/managers.py
+++ b/Lib/multiprocessing/managers.py
@@ -358,10 +358,36 @@ class Server(object):
finally:
self.stop_event.set()
- def create(self, c, typeid, *args, **kwds):
+ def create(*args, **kwds):
'''
Create a new shared object and return its id
'''
+ if len(args) >= 3:
+ self, c, typeid, *args = args
+ elif not args:
+ raise TypeError("descriptor 'create' of 'Server' object "
+ "needs an argument")
+ else:
+ if 'typeid' not in kwds:
+ raise TypeError('create expected at least 2 positional '
+ 'arguments, got %d' % (len(args)-1))
+ typeid = kwds.pop('typeid')
+ if len(args) >= 2:
+ self, c, *args = args
+ import warnings
+ warnings.warn("Passing 'typeid' as keyword argument is deprecated",
+ DeprecationWarning, stacklevel=2)
+ else:
+ if 'c' not in kwds:
+ raise TypeError('create expected at least 2 positional '
+ 'arguments, got %d' % (len(args)-1))
+ c = kwds.pop('c')
+ self, *args = args
+ import warnings
+ warnings.warn("Passing 'c' as keyword argument is deprecated",
+ DeprecationWarning, stacklevel=2)
+ args = tuple(args)
+
with self.mutex:
callable, exposed, method_to_typeid, proxytype = \
self.registry[typeid]
@@ -583,10 +609,13 @@ class BaseManager(object):
util.info('manager serving at %r', server.address)
server.serve_forever()
- def _create(self, typeid, *args, **kwds):
+ def _create(*args, **kwds):
'''
Create a new shared object; return the token and exposed tuple
'''
+ self, typeid, *args = args
+ args = tuple(args)
+
assert self._state.value == State.STARTED, 'server not yet started'
conn = self._Client(self._address, authkey=self._authkey)
try:
@@ -1261,15 +1290,25 @@ if HAS_SHMEM:
_SharedMemoryTracker(f"shmm_{self.address}_{getpid()}")
util.debug(f"SharedMemoryServer started by pid {getpid()}")
- def create(self, c, typeid, *args, **kwargs):
+ def create(*args, **kwargs):
"""Create a new distributed-shared object (not backed by a shared
memory block) and return its id to be used in a Proxy Object."""
# Unless set up as a shared proxy, don't make shared_memory_context
# a standard part of kwargs. This makes things easier for supplying
# simple functions.
+ if len(args) >= 3:
+ typeod = args[2]
+ elif 'typeid' in kwargs:
+ typeid = kwargs['typeid']
+ elif not args:
+ raise TypeError("descriptor 'create' of 'SharedMemoryServer' "
+ "object needs an argument")
+ else:
+ raise TypeError('create expected at least 2 positional '
+ 'arguments, got %d' % (len(args)-1))
if hasattr(self.registry[typeid][-1], "_shared_memory_proxy"):
kwargs['shared_memory_context'] = self.shared_memory_context
- return Server.create(self, c, typeid, *args, **kwargs)
+ return Server.create(*args, **kwargs)
def shutdown(self, c):
"Call unlink() on all tracked shared memory, terminate the Server."