当前位置: 首页>>代码示例>>Python>>正文


Python Worker.start方法代码示例

本文整理汇总了Python中Worker.Worker.start方法的典型用法代码示例。如果您正苦于以下问题:Python Worker.start方法的具体用法?Python Worker.start怎么用?Python Worker.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Worker.Worker的用法示例。


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

示例1: __init__

# 需要导入模块: from Worker import Worker [as 别名]
# 或者: from Worker.Worker import start [as 别名]
 def __init__(self, workerNum=5):
     super(Manager, self).__init__()
     self.workerNum = workerNum
     for i in range(self.workerNum):
         worker = Worker('worker-thread[%d]' %(i), self.workerQueue, func)
         self.workerQueue.put(worker)
         worker.start()
开发者ID:brighthush,项目名称:GeneralThreadPool,代码行数:9,代码来源:Manager.py

示例2: login

# 需要导入模块: from Worker import Worker [as 别名]
# 或者: from Worker.Worker import start [as 别名]
    def login(self, account, password, status, proxy, use_http=False):
        '''start the login process'''
        self.account = e3.Account(account, password, status)
        worker = Worker('emesene2', self, proxy, use_http)
        worker.start()

        self.add_action(e3.Action.ACTION_LOGIN, (account, password, status))
开发者ID:DarKprince,项目名称:emesene2,代码行数:9,代码来源:Session.py

示例3: addWorker

# 需要导入模块: from Worker import Worker [as 别名]
# 或者: from Worker.Worker import start [as 别名]
	def addWorker(self, peer):
		key = peer.key
		if key not in self.workers and len(self.workers) < MAX_WORKERS: # We dont have worker for that peer and workers num less than max
			worker = Worker(self, peer)
			self.workers[key] = worker
			worker.key = key
			worker.start()
			return worker
		else: # We have woker for this peer or its over the limit
			return False
开发者ID:EdenSG,项目名称:ZeroNet,代码行数:12,代码来源:WorkerManager.py

示例4: login

# 需要导入模块: from Worker import Worker [as 别名]
# 或者: from Worker.Worker import start [as 别名]
    def login(self, account, password, status, proxy, host, port, use_http=False):
        """start the login process"""
        worker = Worker("emesene2", self, proxy, use_http)
        worker.start()

        # msn password must have 16 chars max.
        password = password[:16]
        # ------------------------------------
        self.account = e3.Account(account, password, status, host)

        self.add_action(e3.Action.ACTION_LOGIN, (account, password, status, host, port))
开发者ID:Roger,项目名称:emesene,代码行数:13,代码来源:Session.py

示例5: runloop

# 需要导入模块: from Worker import Worker [as 别名]
# 或者: from Worker.Worker import start [as 别名]
	def runloop(self):
		while self.current <= self.end:
			remainLimit = self.limit - threading.activeCount()
			if remainLimit > 0:
				for x in xrange(1, remainLimit):
					uri = uriTemplate % (self.current,)
					self.current += 1
					worker = Worker(uri=uri)
					worker.daemon = True
					worker.start()
					# worker.join()
			
			time.sleep(2)
开发者ID:soulgain,项目名称:MagnetFetcher,代码行数:15,代码来源:Dispatch.py

示例6: Session

# 需要导入模块: from Worker import Worker [as 别名]
# 或者: from Worker.Worker import start [as 别名]
class Session(e3.Session):
    '''a specialization of e3.Session'''
    NAME = 'Jabber session'
    DESCRIPTION = 'Session to connect to the Jabber network'
    AUTHOR = 'Mariano Guerra'
    WEBSITE = 'www.emesene.org'

    SERVICES = {
        "gtalk": {
            "host": "talk.google.com",
            "port": "5223"
        },
        "facebook": {
            "host": "chat.facebook.com",
            "port": "5222"
        }
    }

    def __init__(self, id_=None, account=None):
        '''constructor'''
        e3.Session.__init__(self, id_, account)

    def login(self, account, password, status, proxy, host, port, use_http=False):
        '''start the login process'''
        self.account = e3.Account(account, password, status, host)
        self.__worker = Worker('emesene2', self, proxy, use_http)
        self.__worker.start()

        self.add_action(e3.Action.ACTION_LOGIN, (account, password, status,
            host, port))

    def send_message(self, cid, text, style=None, cedict=None, celist=None):
        '''send a common message'''
        if cedict is None:
            cedict = {}

        if celist is None:
            celist = []

        account = self.account.account
        message = e3.Message(e3.Message.TYPE_MESSAGE, text, account,
            style)
        self.add_action(e3.Action.ACTION_SEND_MESSAGE, (cid, message))

    def request_attention(self, cid):
        '''request the attention of the contact'''
        account = self.account.account
        message = e3.Message(e3.Message.TYPE_MESSAGE,
            '%s requests your attention' % (account, ), account)
        self.add_action(e3.Action.ACTION_SEND_MESSAGE, (cid, message))
开发者ID:19MiRkO91,项目名称:emesene,代码行数:52,代码来源:Session.py

示例7: addWorker

# 需要导入模块: from Worker import Worker [as 别名]
# 或者: from Worker.Worker import start [as 别名]
 def addWorker(self, peer, multiplexing=False, force=False):
     key = peer.key
     if len(self.workers) > self.getMaxWorkers() and not force:
         return False
     if multiplexing:  # Add even if we already have worker for this peer
         key = "%s/%s" % (key, len(self.workers))
     if key not in self.workers:
         # We dont have worker for that peer and workers num less than max
         worker = Worker(self, peer)
         self.workers[key] = worker
         worker.key = key
         worker.start()
         return worker
     else:  # We have woker for this peer or its over the limit
         return False
开发者ID:binerf,项目名称:zeronet_tor,代码行数:17,代码来源:WorkerManager.py

示例8: Session

# 需要导入模块: from Worker import Worker [as 别名]
# 或者: from Worker.Worker import start [as 别名]
class Session(e3.Session):
    '''a specialization of e3.base.Session'''
    NAME = 'Papyon session'
    DESCRIPTION = 'MSN session (papyon)'
    AUTHOR = ", ".join(AUTHOR_LIST)
    WEBSITE = 'www.emesene.org'

    SERVICES = {"msn": {"host": "messenger.hotmail.com", "port": "1863"}}

    def __init__(self, id_=None, account=None):
        '''constructor'''
        e3.Session.__init__(self, id_, account)

    def login(self,
              account,
              password,
              status,
              proxy,
              host,
              port,
              use_http=False):
        '''start the login process'''
        self.__worker = Worker('emesene2', self, proxy, use_http)
        self.__worker.start()

        # msn password must have 16 chars max.
        password = password[:16]

        self.account = e3.Account(account, password, status, host)

        self.add_action(e3.Action.ACTION_LOGIN,
                        (account, password, status, host, port))

    def send_message(self, cid, text, style=None, cedict=None, celist=None):
        '''send a common message'''
        if cedict is None:
            cedict = {}

        if celist is None:
            celist = []

        account = self.account.account
        message = e3.Message(e3.Message.TYPE_MESSAGE, text, account, style)
        self.add_action(e3.Action.ACTION_SEND_MESSAGE,
                        (cid, message, cedict, celist))

    def send_typing_notification(self, cid):
        '''send typing notification to contact'''
        account = self.account.account
        message = e3.Message(e3.Message.TYPE_TYPING, None, account)
        self.add_action(e3.Action.ACTION_SEND_MESSAGE, (cid, message))

    def request_attention(self, cid):
        '''request the attention of the contact'''
        account = self.account.account
        message = e3.Message(e3.Message.TYPE_NUDGE, None, account)
        self.add_action(e3.Action.ACTION_SEND_MESSAGE, (cid, message))

    def conversation_invite(self, cid, account):
        '''invite a contact to a conversation'''
        self.add_action(e3.Action.ACTION_CONV_INVITE, (cid, account))

    def filetransfer_invite(self, cid, account, filename, completepath,
                            preview_data):
        '''send a file to the first user of the conversation'''
        self.add_action(e3.Action.ACTION_FT_INVITE,
                        (cid, account, filename, completepath, preview_data))

    def call_invite(self, cid, account, a_v_both, surface_other, surface_self):
        '''try to start a call with the first user of the conversation'''
        self.add_action(e3.Action.ACTION_CALL_INVITE,
                        (cid, account, a_v_both, surface_other, surface_self))

    def get_worker(self):
        return self.__worker

    def get_profile(self):
        return self.__worker.profile

    # methods for the privacy tab
    def get_blocked_contacts(self):
        '''return a list containing the contacts in the address book with the
        BLOCK flag set'''
        contacts = self.__worker.address_book.contacts
        return [c.account for c in contacts if (Membership.BLOCK & c.memberships) and \
                ((Membership.FORWARD & c.memberships) or (Membership.REVERSE & c.memberships))]

    def get_allowed_contacts(self):
        '''return a list containing the contacts in the address book with the
        ALLOW flag set'''
        contacts = self.__worker.address_book.contacts
        return [c.account for c in contacts if (Membership.ALLOW & c.memberships) and \
                ((Membership.REVERSE & c.memberships) or (Membership.FORWARD & c.memberships))]

    def is_only_reverse(self, account):
        '''return True if the contact has set the REVERSE flag and not the
        FORWARD flag; otherwise False.
        This means, contacts that are not in your contact list but they do have
        you'''
        contacts = self.__worker.address_book.contacts.search_by(
#.........这里部分代码省略.........
开发者ID:hsantanna,项目名称:emesene,代码行数:103,代码来源:Session.py

示例9: Session

# 需要导入模块: from Worker import Worker [as 别名]
# 或者: from Worker.Worker import start [as 别名]
class Session(e3.Session):
    '''a specialization of e3.base.Session'''
    NAME = 'Papyon session'
    DESCRIPTION = 'MSN session (papyon)'
    AUTHOR = ", ".join(AUTHOR_LIST)
    WEBSITE = 'www.emesene.org'

    SERVICES = {
        "msn": {
            "host": "messenger.hotmail.com",
            "port": "1863"
        }
    }

    CAPABILITIES = [e3.Session.SERVICE_CONTACT_MANAGING,
                    e3.Session.SERVICE_CONTACT_ALIAS,
                    e3.Session.SERVICE_CONTACT_BLOCK,
                    e3.Session.SERVICE_CONTACT_INVITE,
                    e3.Session.SERVICE_GROUP_MANAGING,
                    e3.Session.SERVICE_FILETRANSFER,
                    e3.Session.SERVICE_PROFILE_PICTURE,
                    e3.Session.SERVICE_STATUS,
                    e3.Session.SERVICE_CONTACT_NICK,
                    e3.Session.SERVICE_CONTACT_PM,
                    e3.Session.SERVICE_ENDPOINTS]

    def __init__(self, id_=None, account=None):
        '''constructor'''
        e3.Session.__init__(self, id_, account)

    def load_config(self):
        '''load the config of the session'''
        e3.Session.load_config(self)

        self.__worker.profile.end_point_name = self.config.get_or_set("s_papylib_endpoint_name", "emesene")
        # keepalive conversations...or not
        b_keepalive = self.config.get_or_set("b_papylib_keepalive", False)
        self.__worker.keepalive_conversations = b_keepalive
        # disconnect other endpoints...or not
        b_dc_ep = self.config.get_or_set("b_papylib_disconnect_ep", False)
        if b_dc_ep:
            self.add_action(e3.Action.ACTION_DISCONNECT_OTHER_ENDPOINTS)
        # we fire the event for every endpoint because otherwise we lose
        # endpoints that were present before we logged in
        for endp in self.__worker.profile.end_points.values():
            self.__worker._on_profile_end_point_added(endp)

    def login(self, account, password, status, proxy, host, port,
              use_http=False, use_ipv6=False):
        '''start the login process'''
        self.__worker = Worker(self, proxy, use_http, use_ipv6)
        self.__worker.start()

        # msn password must have 16 chars max.
        password = password[:16]

        self.account = e3.Account(account, password, status, host)

        self.add_action(e3.Action.ACTION_LOGIN, (account, password, status,
            host, port))

    def send_message(self, cid, text, style=None, cedict=None, celist=None):
        '''send a common message'''
        if cedict is None:
            cedict = {}

        if celist is None:
            celist = []

        account = self.account.account
        message = e3.Message(e3.Message.TYPE_MESSAGE, text, account,
            style)
        self.add_action(e3.Action.ACTION_SEND_MESSAGE, (cid, message, cedict, celist))

    def send_typing_notification(self, cid):
        '''send typing notification to contact'''
        account = self.account.account
        message = e3.Message(e3.Message.TYPE_TYPING, None, account)
        self.add_action(e3.Action.ACTION_SEND_MESSAGE, (cid, message))

    def request_attention(self, cid):
        '''request the attention of the contact'''
        account = self.account.account
        message = e3.Message(e3.Message.TYPE_NUDGE, None, account)
        self.add_action(e3.Action.ACTION_SEND_MESSAGE, (cid, message))

    def conversation_invite(self, cid, account):
        '''invite a contact to a conversation'''
        self.add_action(e3.Action.ACTION_CONV_INVITE, (cid, account))

    def filetransfer_invite(self, cid, account, filename, completepath, preview_data):
        '''send a file to the first user of the conversation'''
        self.add_action(e3.Action.ACTION_FT_INVITE, (cid, account, filename, completepath, preview_data))

    def call_invite(self, cid, account, a_v_both, surface_other, surface_self):
        '''try to start a call with the first user of the conversation'''
        self.add_action(e3.Action.ACTION_CALL_INVITE, (cid, account, a_v_both, surface_other, surface_self))

    def get_worker(self):
        return self.__worker
#.........这里部分代码省略.........
开发者ID:AmiZya,项目名称:emesene,代码行数:103,代码来源:Session.py

示例10: function

# 需要导入模块: from Worker import Worker [as 别名]
# 或者: from Worker.Worker import start [as 别名]
#!/usr/bin/env python3

from Worker import Worker
from time import sleep

def function(inputs):
  sleep(3)
  return {
    "res": inputs['key2'] * 2
  }

worker = Worker(5,1)


worker.start(function)
开发者ID:fm2g11,项目名称:CluJoDEn,代码行数:17,代码来源:sampleWorker.py

示例11: Session

# 需要导入模块: from Worker import Worker [as 别名]
# 或者: from Worker.Worker import start [as 别名]
class Session(e3.Session):
    '''a specialization of e3.Session'''
    NAME = 'WebQQ Session'
    DESCRIPTION = 'Session to connect to the WebQQ network'
    AUTHOR = 'Cj Tian ([email protected])'
    WEBSITE = 'www.emesene.org'

    SERVICES = {
        "webqq": {
            "host": "web.qq.com",
            "port": "80"
        },
    }

    def __init__(self, id_=None, account=None):
        '''constructor'''
        e3.Session.__init__(self, id_, account)
        # FIXME: set qq emoticons
        self.config.get_or_set('emote_theme', 'default')

    def login(self, account, password, status, proxy, host, port , use_http=False, use_ipv6=None):
        '''start the login process'''

        self.account = e3.Account(account, password, status, host)

        self.__worker = Worker('emesene2', self, proxy, use_http)
        self.__worker.start()
        print "add e3.Action.ACTION_LOGIN"
        self.add_action(e3.Action.ACTION_LOGIN, (account, password, status,
            host, port))

    def get_conv_parser(self):
        return self.__worker._markup_rawparse

    def send_message(self, cid, text, style=None, cedict=None, celist=None):
        '''send a common message'''
        if cedict is None:
            cedict = {}

        if celist is None:
            celist = []

        account = self.account.account
        message = e3.Message(e3.Message.TYPE_MESSAGE, text, account,
            style)
        self.add_action(e3.Action.ACTION_SEND_MESSAGE, (cid, message))

    def send_typing_notification(self, cid):
        '''send typing notification to contact'''
        ##FIXME: implement this
        pass

    def send_picture(self, cid, account, filename, completepath, preview_data):
        '''send a file to the first user of the conversation'''
        self.add_action(e3.Action.ACTION_SEND_PICTURE, (cid, account, filename, completepath, preview_data))

    def session_has_service(self, service):
        '''returns True if some service is supported, False otherwise'''
        if service in [Session.SERVICE_CONTACT_MANAGING,
                        Session.SERVICE_CONTACT_BLOCK,
                        Session.SERVICE_CONTACT_ALIAS,
                        Session.SERVICE_GROUP_MANAGING,
                        Session.SERVICE_CONTACT_INVITE,
                        Session.SERVICE_CALLS,
            #            Session.SERVICE_STATUS,
            #            Session.SERVICE_FILETRANSFER
                        ]:
            return False
        else:
            return True

    def request_attention(self, cid):
        '''request the attention of the contact'''
        account = self.account.account
        message = e3.Message(e3.Message.TYPE_MESSAGE,
            '%s requests your attention' % (account, ), account)
        self.add_action(e3.Action.ACTION_SEND_ATTENTION, (cid,))
开发者ID:tiancj,项目名称:emesene,代码行数:79,代码来源:Session.py

示例12: range

# 需要导入模块: from Worker import Worker [as 别名]
# 或者: from Worker.Worker import start [as 别名]
    random.seed()

    # Probably only 4 cores available
    num_workers = 4
    workers = []
    incoming_data_channels = [] 
    for i in range(num_workers):

        admin_channel = multiprocessing.Pipe()
        results_channel = multiprocessing.Pipe()

        results_send, results_receive = results_channel
        incoming_data_channels.append(results_receive)
        worker = Worker(admin_channel, results_send)
        workers.append(worker)
        worker.start()
  
    task_master = TaskMaster(workers)
    task_master.start()

    try:
        event_loop(incoming_data_channels)
    except KeyboardInterrupt:
        pass

    log('KeyboardInterrupt: Collecting processes and terminating') 
    task_master.enough()
    task_master.join()
    for w in workers:
        w.send(['stop', []])
        w.join()
开发者ID:jelford,项目名称:non-blocking-workpool,代码行数:33,代码来源:lexec.py


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