question about multiprocessing
hywhy
hywhy at live.com
Sat Jun 26 10:54:09 EDT 2010
thanks,firend. I have a try with SyncManager, Is there any problem in my
code?
from multiprocessing.managers import SyncManager,BaseProxy
import multiprocessing
import Queue
class ResourceController(object):
def __init__(self):
self.text = 'Hello world!'
self.queue = multiprocessing.Queue()
self.queue.put('I am queue')
def say(self):
print self.text
def get_queue(self):
return self.queue
class ResourceProxy(BaseProxy):
def say_hello(self):
return self._callmethod('say')
def get_queue(self):
return self._callmethod('get_queue')
class CrawlerManager(SyncManager):
def __init__(self):
SyncManager.__init__(self)
self.register('ResourceController', ResourceController,
ResourceProxy)
if __name__ == '__main__':
cm = CrawlerManager()
cm.start()
rc = cm.ResourceController()
rc.say_hello()
q = rc.get_queue()
print q.get()
--
View this message in context: http://old.nabble.com/question-about-multiprocessing-tp28940614p29000781.html
Sent from the Python - python-list mailing list archive at Nabble.com.
More information about the Python-list
mailing list