def save_unicode(self, tag, data): binary=self.binary v='' a=data[1] if len(data)>2: for x in data[2:]: v=v+x encoding=a.get('encoding','repr') # JPS: repr is default encoding if encoding is not '': v=unconvert(encoding,v) if binary: l=len(v) s=mdumps(l)[1:] v=BINUNICODE+s+v else: v=UNICODE+"'"+v+"'\012" return save_put(self, v, a)
def fork(self, target, args, callback= None, priority= None, job_id= None, **properties): """ Turns the target method to be forked into byte-code and creates a Job. The Job is initialized to the starting state and placed the the streams priorty queue for execution. """ if self.properties.get('mss'): stall_time= 1 while len(self.store) > int(self.properties.get('mss')): print "throttling size %s exceeds mss %s" % (len(self.store), self.properties.get('mss')) sleep(stall_time) stall_time+= 1 if stall_time >= 10: break current_thread= currentThread() job= Job( client= {"id": self.id, "ipaddress": self.ipaddress}, name= target.func_name, code= encode(compress(mdumps(target.func_code))), args= args, callback= callback if callback else current_thread.next_thread.name, result= None, transport= None, **properties ) if priority: setattr(job, "priority", priority) self.store.update([(job.get("id"), job)]) self.queue.put([(job.get("priority"), job.get("id"))]) #print "forked", len(self.store) self.jobs.append(job.get("id")) self._thread_progress(current_thread.name, "forked", 1) return job.get("id")
def save_string(self, tag, data): binary=self.binary v='' a=data[1] if len(data)>2: v = ''.join(data[2:]) encoding=a.get('encoding','repr') # JPS: repr is default encoding if encoding is not '': v=unconvert(encoding,v) put='p' if binary: l=len(v) s=mdumps(l)[1:] if (l<256): v='U'+s[0]+v else: v='T'+s+v put='q' else: v="S'"+v+"'\012" return save_put(self, v, a)
def save_string(self, tag, data): binary = self.binary v = "" a = data[1] if len(data) > 2: v = "".join(data[2:]) encoding = a.get("encoding", "repr") # JPS: repr is default encoding if encoding is not "": v = unconvert(encoding, v) put = "p" if binary: l = len(v) s = mdumps(l)[1:] if l < 256: v = "U" + s[0] + v else: v = "T" + s + v put = "q" else: v = "S'" + v + "'\012" return save_put(self, v, a)