def worker_post_message(cls, key, payload): """ Send a message to the workpool on stdout. Called by a worker. """ msg = cls.build_message(key, payload) ns = netstring.encode(msg) sys.stdout.write(ns) sys.stdout.flush()
def worker_post_message( cls, key, payload ): """ Send a message to the workpool on stdout. Called by a worker. """ msg = cls.build_message( key, payload ) ns = netstring.encode( msg ) sys.stdout.write( ns ) sys.stdout.flush()
def read(self, size): size=640 * 1024 tmp=[] totlen = 0 if self._tmp: a, self._tmp = self._tmp, None return a for i in self.it: s = netstring.encode(pickle.dumps(i, pickle.HIGHEST_PROTOCOL)) l = len(s) if totlen==0 and l>size: raise Exception() elif l+totlen>size: self.totalsize+=totlen #ASD self._tmp = s return ''.join(tmp) else: tmp.append(s) totlen+=l self.totalsize+=totlen # return ''.join(tmp)
def writemsg(self, wfd, msg): """ Write message to stdin. Return True if successfully flushed Return False if we had to carry some over. Return None if the process is dead. NOTE: call flush() first, and only call this method if flush() returns True. """ nm = netstring.encode(msg) rc = self.write_or_carry(wfd, nm) if rc is None: # process died return None if not rc: # carried return False # success! return True
def writemsg( self, wfd, msg ): """ Write message to stdin. Return True if successfully flushed Return False if we had to carry some over. Return None if the process is dead. NOTE: call flush() first, and only call this method if flush() returns True. """ nm = netstring.encode( msg ) rc = self.write_or_carry( wfd, nm ) if rc is None: # process died return None if not rc: # carried return False # success! return True