def _tickloop(self): while (self._run): n = mt.time() if n - self._lasttick > self._sleeptime: self._lasttick = n self._runloop() time.sleep(0.01)
def publish(self, value=None, mtype=Message.GENERAL): m = {'type': mtype, 'source': self.channel, 'ts': mt.time()} if self._location: m['location'] = self._location if value is not None: try: m['value'] = json.loads(value) except: m['value'] = value self._redis.publish(self.channel, json.dumps(m))
def send_thread(): c_cnt = 1 while c_cnt <= num_chunks: s_time = mtime.time() print "Started chunk {} at {}".format(c_cnt, s_time) chunk, bcs = run_q.get() print "Got a chunk {} cs={}".format(chunk, bcs) s = mpup.upload_part_from_file(chunk, part_num=c_cnt) if s.size != r_size and c_cnt < num_chunks: raise Exception("Send size {} != chunck size {}".format( s, r_size)) e_tag = s.etag.replace('"', '') if e_tag != bcs: raise Exception( "MD5 of uploaded chunk ({}) != ours ({})".format( e_tag, bcs)) print "sent chunk, saw etag {}".format(e_tag) d_time = mtime.time() - s_time print "[{:04}] {}s -> waiting {}".format(c_cnt, d_time, 1.0 - d_time) time.sleep(1.0 - d_time) c_cnt += 1
def sinkProcessedImage(self, p): el = mtime.time() - self._st eprint("[{:6.2f}%, {:05}/{:05}, {:6.3f}m elapsed] {}".format( (float(self._count) / self._ex) * 100, self._count, self._ex, (el / 60.0), p['path'])) self._count += 1
def preprocess(self, num): self._ex = num self._st = mtime.time()