本文整理汇总了Python中Worker.Worker类的典型用法代码示例。如果您正苦于以下问题:Python Worker类的具体用法?Python Worker怎么用?Python Worker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Worker类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: login
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))
示例2: add_questions_to_sentences
def add_questions_to_sentences(resultlines, categories, tasks):
"""Adds the Questions to the Sentences in the Tasks (phew), reading the worker's
data from resultlines (a list of lines from the result file) and using the
dictionary categories to put the Questions in the correct places.
pre: resultlines is a list of lines from the result file, categories is a
hash table based on metadata strings.
post: Returns the task dictionary."""
workers = []
for rline in resultlines: #For each worker's data...
l = rline.split("\t") #Make it a list of data
workerID = l[19] #Retrieve workerID
l = map(deleteQuotes,l) #Delete all the unnecessary quotes
worker = Worker(workerID, l[29])
workers.append(worker)
currentTask = tasks[ l[29] ] #Find the Task that the worker is working on (taskID @l[29])
#print currentTask.get_ID()
currentTask = __add_questions(l, currentTask, categories, worker) #Add the questions where they should go
#currentTask.add_worker(worker)
#print len(currentTask.get_workers())
for worker in workers:
taskID = worker.get_taskID()
task = tasks[taskID]
if task.get_ID()==taskID:
task.add_worker(worker)
#print len(
return tasks
示例3: __init__
def __init__(self):
Worker.__init__(self, "Worker Rolling Average Subtraction")
#Class specific variables
self.averagedBuffer = None
self.datFiles = []
self.datIndex = 1
示例4: __init__
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()
示例5: __init__
def __init__(self):
Worker.__init__(self, "WorkerDB")
self.db = None
#Specific ZMQ stuff for WorkerDB, it uses SUB/PUB
self.sub = self.context.socket(zmq.SUB)
示例6: clear
def clear(self):
"""
Calls super clear(), removes averaged buffer, sets index back to 1 and clears out all datFiles
"""
Worker.clear(self)
self.averagedBuffer = None
self.datFiles = []
self.datIndex = 1
示例7: clear
def clear(self):
"""
Calls super clear() and then the workers specific requirements
"""
Worker.clear(self)
self.averagedBuffer = None
self.bufferIndex = 1
self.buffers = []
示例8: __init__
def __init__(self, **kwargs):
Worker.__init__(self, "Worker Buffer Average")
#Specific Class Variables
self.averagedBuffer = None
self.bufferIndex = 1
self.buffers = []
self.averagedIntensities = None
self.previousName = None
示例9: addWorker
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
示例10: login
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))
示例11: __init__
def __init__(self):
Worker.__init__(self, "WorkerStaticImage")
self.subtractedDatIntensities = []
self.subtractedDatq = []
self.subtractedErrors = []
#For adding to be cleared when new user/sample
self.addToClearList(self.subtractedDatIntensities)
self.addToClearList(self.subtractedDatq)
self.addToClearList(self.subtractedErrors)
示例12: runloop
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)
示例13: Session
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))
示例14: __init__
def __init__(self):
Worker.__init__(self, "Worker Buffer Average")
#Specific Class Variables
self.averagedBuffer = None
self.bufferIndex = 1
self.buffers = []
self.averagedIntensities = None
self.previousName = None
#specific ZMQ
self.context = zmq.Context()
self.reply = self.context.socket(zmq.REP)
示例15: addWorker
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