• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python managers.BaseManager类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中multiprocessing.managers.BaseManager的典型用法代码示例。如果您正苦于以下问题:Python BaseManager类的具体用法?Python BaseManager怎么用?Python BaseManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了BaseManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: create

 def create(self, name, **ctor_args):
     ''' Create a :class:`ConsoleServer` and return a proxy for it. 
     '''
     manager = BaseManager()
     manager.register('ConsoleServer', ConsoleServer)
     manager.start()
     return manager.ConsoleServer()
开发者ID:JustinSGray,项目名称:OpenMDAO-Framework,代码行数:7,代码来源:consoleserverfactory.py


示例2: run

 def run(self):
     while not self.is_stop:
         mgr = BaseManager(address=('', 7777), authkey='xxx')
         s = mgr.get_server()
         s.serve_forever()
         i = 1
         i += 1
开发者ID:lowitty,项目名称:zacademy,代码行数:7,代码来源:server.py


示例3: __init__

 def __init__(self):
     self.config.read('config.ini')
     BaseManager.register('Queue', queue.Queue)
     manager = BaseManager()
     manager.start()
     self.queue = manager.Queue()
     self.threads = {
         'sensorreading_submitter': {
             'last_run': None,
             'timeout': int(self.config.get('api', 'submit_sensorreadings_interval')),
             'thread': None
         },
         'desired_state_fetcher': {
             'last_run': None,
             'timeout': int(self.config.get('api', 'fetch_desired_states_interval')),
             'thread': None
         },
         'sensorreading_buffer': {
             'last_run': None,
             'timeout': int(self.config.get('api', 'sensorreading_buffer_flush_interval')),
             'thread': None
         },
         'maintenance': {
             'last_run': None,
             'timeout': int(self.config.get('api', 'maintenance_interval')),
             'thread': None
         }
     }
开发者ID:dasprot,项目名称:ciliatus_controlunit,代码行数:28,代码来源:app.py


示例4: make_simple_server_manager

def make_simple_server_manager(ip,port, authkey):
	print "starting server..."
	manager = BaseManager(address=('', 50000), authkey='abc')
	server = manager.get_server()
	server.serve_forever()
	print "started"
	return manager
开发者ID:yadu-jain,项目名称:dist_it,代码行数:7,代码来源:manage_server.py


示例5: __init__

 def __init__(self,address='127.0.0.1',port=6666,authkey='',rootDomain='',digSubDomain=False,threads_num=1):
     
     BaseManager.__init__(self,(address,int(port)),authkey)
     task_queue_n=Queue.Queue()
     response_queue_n=Queue.Queue()
     
     # self.address=address
     self.port=port
     self.authkey=authkey
     self.register('task_queue_n',callable=lambda:task_queue_n)
     self.register('response_queue_n',callable=lambda:response_queue_n)
      
     # self.tasks=[]  #记录自己已经访问过的域名,或者路径 
     
     self.digSubDomain=digSubDomain
     self.DnsThread=None 
     self.httpserverThread=None         
     self.START_FLAG=True     
     self.count=0   #访问错误计数
     self.delay=0  #延时时间 
     
     self.threads_num=threads_num #爆破子域名的线程数
     if self.digSubDomain:
         
         self.domain=domainRecorder(rootDomain=rootDomain,domain=rootDomain,path='/',isSubDomain=True)
         
     else:
         self.domain=domainRecorder(rootDomain=rootDomain,domain=rootDomain,path='/',isSubDomain=False)
     
     self.domainCount=0
开发者ID:wonderkun,项目名称:spider,代码行数:30,代码来源:server.py


示例6: __init__

    def __init__(self, address=None, authkey=None, serialize='pickle',
                 ctx=None):
        BaseManager.__init__(self, address, authkey, serialize, ctx)
        self.task_queue, self.result_queue = None, None

        # callable使用lambda报错
        self.register('get_task_queue', callable=return_task_queue)
        self.register('get_result_queue', callable=return_result_queue)
开发者ID:wayne0429,项目名称:Study,代码行数:8,代码来源:task_master.py


示例7: start

    def start(self):
        BaseManager.start(self)

        # 加载任务队列和结果队列
        if not self.task_queue:
            self.task_queue = self.get_task_queue()

        if not self.result_queue:
            self.result_queue = self.get_result_queue()
开发者ID:wayne0429,项目名称:Study,代码行数:9,代码来源:task_master.py


示例8: _setup

    def _setup(self):
        free_phy_mem = available_memory(percent=35)
        maxsize = int(free_phy_mem / BLOCK_SIZE)
        self._input_buffer = self.manager.Queue(maxsize)
        self.output_buffer = self.manager.Queue(maxsize)

        BaseManager.register("ReoderBuffer", ReoderBuffer)
        bm = BaseManager()
        bm.start()
        self.reorder_buffer = bm.ReoderBuffer(self.output_buffer, 50)
开发者ID:igorbonadio,项目名称:carbono,代码行数:10,代码来源:work_manager.py


示例9: __init__

    def __init__(self, address, authkey):
        BaseManager.__init__(self, address, authkey)
        self.srvAddr = address
        self.srvKey = authkey

        AgentManager.register("get")
        AgentManager.register("load")
        AgentManager.register("readFile")
        AgentManager.register("writeFile")
        AgentManager.register("printmsg")

        self.localattrs = dict()
开发者ID:nihilus,项目名称:toolbag,代码行数:12,代码来源:agentmanager.py


示例10: __init__

 def __init__(self):
     BaseManager.__init__(self,address=(Parameter.SERVER, Parameter.PORT), authkey=Parameter.PASSWORD)
     self._manager = Manager()
     self._coordinates = self._manager.Queue()
     self._values = self._manager.Queue()
     self._lock = self._manager.Lock()
     self._clientCounter = self._manager.Value('i', 0)
     self.register('clientStart', self.addClient)
     self.register('clientDone', self.removeClient)
     self.register('getCoordinatesLock', self.getCoordinatesLock)
     self.register('getCoordinatesQueue', self.getCoordinates)
     self.register('getValuesQueue', self.getValues)
开发者ID:Schille,项目名称:MagneticPendulum,代码行数:12,代码来源:ClusterQueueManager.py


示例11: __init__

 def __init__(self, host=None, port=None, authkey=None, delmult=1, replaceterm=None, replacewith=None, name='1', delinprod=True):
     self.name = name
     self.host = host
     self.port = port
     self.authkey = authkey
     self.delinprod = delinprod
     print 'Initializing LogParser: ' + self.name + ' as BaseManager(address=(' + host + ', ' + str(port) + ', authkey=' + authkey + ') with remote queues'
     BaseManager.register('get_log_queue')
     self.m = BaseManager(address=(host, port), authkey=authkey)
     self.m.connect()
     self.queue = self.m.get_log_queue()
     self.delmult = delmult
     self.replaceterm = replaceterm
     self.replacewith = replacewith
开发者ID:daubman,项目名称:solr-replay,代码行数:14,代码来源:LogParser.py


示例12: connect

    def connect(self, pythonexec=None, parent=None):
        "Custom connection method that will start up a new server"

        # fork a new server process with correct python interpreter (py3/venv)
        if pythonexec:
            # warning: this will not work frozen? (ie. py2exe)
            command = pythonexec + " -u %s --server" % __file__

            import wx
            
            class MyProcess(wx.Process):
                "Custom Process Class to handle OnTerminate event method"

                def OnTerminate(self, pid, status):
                    "Clean up on termination (prevent SEGV!)"
                
                def OnClose(self, evt):
                    "Termitate the process on exit"
                    # prevent the server continues running after the IDE closes
                    print("closing pid", self.GetPid())
                    self.Kill(self.GetPid())
                    print("killed")


            self.process = MyProcess(parent)
            parent.Bind(wx.EVT_CLOSE, self.process.OnClose)
            #process.Redirect()
            flags = wx.EXEC_ASYNC
            if wx.Platform == '__WXMSW__':
                flags |= wx.EXEC_NOHIDE
            wx.Execute(command, flags, self.process)

            return BaseManager.connect(self)
开发者ID:reingart,项目名称:rad2py,代码行数:33,代码来源:autocompletion.py


示例13: QueueServer

class QueueServer(object):

    def __init__(self, queue_server_host, queue_server_port, queue_server_authkey=None):
        '''
            host,port defines where your queuing server should be running while *authkey* 
            is going to be used to authenticate any communication between this queue server
            and clients connected to it. Clients will need to send the *authkey* to connect
            this queue server.
        '''
        self.host = queue_server_host
        self.port = queue_server_port
        self.authkey = queue_server_authkey

        '''
        Lets just say, we have a client that wants to put some image realted data into database 
        and also want to generate thumbnails from it (You know, where it is going,
        I'll give you a hint, checkout my last post about multi-threading)
        '''
        database_queue = Queue()
        thumbnail_queue = Queue()
        
        '''now we have a queue, but if since we want our clients to use it
        we'll need to register this queue with BaseManager via some callable that our client 
        can use to generate the proxy object. Yes, clients will be actually
        able to get the (proxy) object of this Queue and for them, they can
        pretty much use it like a regular queue (however, internally, BaseManager
        will be proxying that data sharing between client and server (and thats the 
        fun, we don't have to worry about locking, shared memory handling etc as 
        BaseManager will handle that, and for us it will be like using Queue between
        threads'''
        BaseManager.register('database_queue', callable=lambda:database_queue)
        BaseManager.register('thumbnail_queue', callable=lambda:thumbnail_queue)

        '''Now that we have registered our queue with BaseManager, we can instantiate
        manager object and start the server. As mentioned, BaseManager will spawn a 
        server in a subprocess and will handle all the communcation and data synchronization'''
        self.manager = BaseManager(address=(self.host, self.port), 
                                   authkey=self.authkey)
        
    def start(self):
        print 'Starting Server Process...'
        self.manager.start()
        
    def stop(self):
        self.manager.shutdown()
开发者ID:eulhaque,项目名称:avoid-picture-duplication---reclaim-your-space,代码行数:45,代码来源:server.py


示例14: start

 def start(self, controller):
     self.controller = controller
     self.register('get_controller', self.get_controller)
     if not self.try_next_port:
         self.get_server().serve_forever()
     host, port = self.address
     while self.try_next_port:
         try:
             BaseManager.__init__(self, (host,port), self.authkey)
             self.get_server().serve_forever()
             self.try_next_port = False
         except socket.error as e:
             try_next_port = False
             import errno
             if e.errno == errno.EADDRINUSE:
                 port += 1
             else:
                 raise
开发者ID:sabago,项目名称:pysph,代码行数:18,代码来源:solver_interfaces.py


示例15: __init__

    def __init__(self):
        BaseManager.register('get_task_queue')
        BaseManager.register('get_result_queue')

        server_addr = '127.0.0.1'
        print ('Connect to server %s...' % server_addr)

        self.m=BaseManager(address=(server_addr,8001),authkey='qiye'.encode('utf-8'))
        print 'connecting...'
        self.m.connect()
        print 'connected'

        self.task = self.m.get_task_queue()
        self.result = self.m.get_result_queue()

        self.downloader = HtmlDownloader()
        self.parser = HtmlParser()
        print 'spider init finish'
开发者ID:cawind2,项目名称:TestTu,代码行数:18,代码来源:SpiderWork.py


示例16: SpiderWork

class SpiderWork(object):
    def __init__(self):
        BaseManager.register('get_task_queue')
        BaseManager.register('get_result_queue')

        server_addr = '127.0.0.1'
        print ('Connect to server %s...' % server_addr)

        self.m=BaseManager(address=(server_addr,8001),authkey='qiye'.encode('utf-8'))
        print 'connecting...'
        self.m.connect()
        print 'connected'

        self.task = self.m.get_task_queue()
        self.result = self.m.get_result_queue()

        self.downloader = HtmlDownloader()
        self.parser = HtmlParser()
        print 'spider init finish'


    def crawl(self):
        while True:
            try:
                # print self.task
                if not self.task.empty():
                    url = self.task.get()

                    if url == 'end':
                        print ('stop...')
                        # 通知其它节点停止
                        self.result.put({'new_urls':'end','data':'end'})
                        return
                    print ('spider is working on %s'%url)
                    content = self.downloader.download(url)
                    new_urls, data = self.parser.parser(url, content)
                    self.result.put({'new_urls':new_urls,'data':data})
            except EOFError as e:
                print 'cannot connect other'
                return
            except Exception as e:
                print e
                print 'crawl fail'
开发者ID:cawind2,项目名称:TestTu,代码行数:43,代码来源:SpiderWork.py


示例17: __init__

	def __init__(self):
		class QueueManager(BaseManager):
    			pass
    			# 由于这个QueueManager只从网络上获取Queue,所以注册时只提供名字:
		BaseManager.register('get_task_queue')
		BaseManager.register('get_result_queue')
		# 连接到服务器,也就是运行taskmanager.py的机器:
		server_addr = '10.1.142.100'
		print('Connect to server %s...' % server_addr)
		# 端口和验证码注意保持与taskmanager.py设置的完全一致:
		m = BaseManager(address=(server_addr, 8888), authkey='abc')
		# 从网络连接:
		m.connect()
		# 获取Queue的对象:
		self.task = m.get_task_queue()
		self.result = m.get_result_queue()
开发者ID:PatricKuo,项目名称:AFOJ-Core,代码行数:16,代码来源:judgeclient.py


示例18: SlaveWork

class SlaveWork(object):

    def __init__(self):

        #初始化分布式进程中的工作节点的链接工作
        #实现第一步,使用basemanager注册获取queue的方法名称
        BaseManager.register('get_task_queue')
        BaseManager.register('get_result_queue')

        ##实现第二步,连接到服务器
        server_addr = '127.0.0.1'
        # 端口和验证口令注意保持与服务进程设置的完全一致:
        self.m = BaseManager(address=(server_addr, 8081), authkey='seven')
        # 从网络连接:
        self.m.connect()

        ##实现第三步
        self.task = self.m.get_task_queue()
        self.result = self.m.get_result_queue()

        ##初始化网页下载器和解析器
        self.downloader = HtmlDownloader()
        self.parser = HtmlParse()

    def crawl(self):
        while(True):
            try:
                if not self.task.empty():
                    url = self.task.get()
                    if url =='end':
                        print("控制节点通知爬虫节点停止工作")
                        self.result.put({'new_urls':'end','data':'end'})
                        return
                    print('爬虫节点正在解析:%s' % url.encode('utf-8'))
                    content = self.downloader.download(url)
                    new_urls, data = self.parser.parser(url, content)
                    self.result.put({"new_urls": new_urls, "data": data})
            except EOFError:
                print("连接工作节点失败")
                return
            except Exception:
                print('Crawl  fali ')
开发者ID:shisiying,项目名称:crawer_python,代码行数:42,代码来源:SlaveWork.py


示例19: __init__

 def __init__(self, host=None, port=None, authkey=None, baseurl=None, name='1', wq=None, rq=None, delinprod=True):
     self.name = name
     self.baseurl = baseurl
     self.delinprod = delinprod
     self.m = None
     if wq is None or rq is None:
         print 'Initializing RequestGenerator: ' + self.name + ' as BaseManager(address=(' + host + ', ' + str(port) + ', authkey=' + authkey + ') with remote queues'
         BaseManager.register('get_work_queue')
         BaseManager.register('get_result_queue')
         self.m = BaseManager(address=(host, port), authkey=authkey)
         self.m.connect()
         self.work_queue = self.m.get_work_queue()
         self.result_queue = self.m.get_result_queue()
     else:
         print 'Initializing RequestGenerator: ' + self.name + ' with shared local queues'
         self.work_queue = wq
         self.result_queue = rq
     #self.work_queue.cancel_join_thread()
     #self.result_queue.cancel_join_thread()
     self.http = urllib3.PoolManager()
开发者ID:daubman,项目名称:solr-replay,代码行数:20,代码来源:RequestGenerator.py


示例20: __init__

    def __init__(self, address, authkey):
        BaseManager.__init__(self, address, authkey)
        self.agentData = address[0], address[1], authkey

        self.srvAddr = address
        self.srvKey = authkey

        # remoteTask is task object remotely instantiated in the agent
        self.remoteTask = None

        # toolbagTask is toolbag's local copy
        self.toolbagTask = None

        AgentManager.register("get")
        AgentManager.register("load")
        AgentManager.register("readFile")
        AgentManager.register("writeFile")
        AgentManager.register("printmsg")

        self.localattrs = dict()
开发者ID:IDA-RE-things,项目名称:toolbag,代码行数:20,代码来源:agentmanager.py



注:本文中的multiprocessing.managers.BaseManager类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python managers.SyncManager类代码示例发布时间:2022-05-27
下一篇:
Python forking.Popen类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap