mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
Merged revisions 65864 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r65864 | jesse.noller | 2008-08-19 14:06:19 -0500 (Tue, 19 Aug 2008) | 2 lines issue3352: clean up the multiprocessing API to remove many get_/set_ methods and convert them to properties. Update the docs and the examples included. ........
This commit is contained in:
parent
be2c2b2313
commit
58ea9fedc8
15 changed files with 86 additions and 92 deletions
|
|
@ -17,10 +17,10 @@ import shutil
|
|||
import subprocess
|
||||
import logging
|
||||
import itertools
|
||||
import Queue
|
||||
import queue
|
||||
|
||||
try:
|
||||
import cPickle as pickle
|
||||
import pickle as pickle
|
||||
except ImportError:
|
||||
import pickle
|
||||
|
||||
|
|
@ -152,7 +152,7 @@ class DistributedPool(pool.Pool):
|
|||
|
||||
def LocalProcess(**kwds):
|
||||
p = Process(**kwds)
|
||||
p.set_name('localhost/' + p.get_name())
|
||||
p.set_name('localhost/' + p.name)
|
||||
return p
|
||||
|
||||
class Cluster(managers.SyncManager):
|
||||
|
|
@ -210,7 +210,7 @@ class Cluster(managers.SyncManager):
|
|||
self._base_shutdown()
|
||||
|
||||
def Process(self, group=None, target=None, name=None, args=(), kwargs={}):
|
||||
slot = self._slot_iterator.next()
|
||||
slot = next(self._slot_iterator)
|
||||
return slot.Process(
|
||||
group=group, target=target, name=name, args=args, kwargs=kwargs
|
||||
)
|
||||
|
|
@ -231,7 +231,7 @@ class Cluster(managers.SyncManager):
|
|||
# Queue subclass used by distributed pool
|
||||
#
|
||||
|
||||
class SettableQueue(Queue.Queue):
|
||||
class SettableQueue(queue.Queue):
|
||||
def empty(self):
|
||||
return not self.queue
|
||||
def full(self):
|
||||
|
|
@ -243,7 +243,7 @@ class SettableQueue(Queue.Queue):
|
|||
try:
|
||||
self.queue.clear()
|
||||
self.queue.extend(contents)
|
||||
self.not_empty.notify_all()
|
||||
self.not_empty.notifyAll()
|
||||
finally:
|
||||
self.not_empty.release()
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import sys
|
|||
def calculate(func, args):
|
||||
result = func(*args)
|
||||
return '%s says that %s%s = %s' % (
|
||||
multiprocessing.current_process().get_name(),
|
||||
multiprocessing.current_process().name,
|
||||
func.__name__, args, result
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -224,7 +224,7 @@ def test_sharedvalues():
|
|||
p.start()
|
||||
p.join()
|
||||
|
||||
assert p.get_exitcode() == 0
|
||||
assert p.exitcode == 0
|
||||
|
||||
|
||||
####
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ if sys.platform == 'win32':
|
|||
|
||||
|
||||
def note(format, *args):
|
||||
sys.stderr.write('[%s]\t%s\n' % (current_process().get_name(),format%args))
|
||||
sys.stderr.write('[%s]\t%s\n' % (current_process().name, format%args))
|
||||
|
||||
|
||||
class RequestHandler(SimpleHTTPRequestHandler):
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ def worker(input, output):
|
|||
def calculate(func, args):
|
||||
result = func(*args)
|
||||
return '%s says that %s%s = %s' % \
|
||||
(current_process().get_name(), func.__name__, args, result)
|
||||
(current_process().name, func.__name__, args, result)
|
||||
|
||||
#
|
||||
# Functions referenced by tasks
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue