def pre_start(self, monitor=None, count=1000): if not monitor: monitor = self.monitor = self.spawn(Monitor, name='monitor') else: self.monitor = monitor = lookup(monitor) if isinstance(monitor, basestring) else monitor NUM = count for i in range(NUM): self.watch(DemoClient.using(monitor=monitor), name='client%s' % str(i + 1).rjust(len(str(NUM)), '0'))
def pre_start(self, monitor=None, count=1000): if not monitor: monitor = self.monitor = self.spawn(Monitor, name='monitor') else: self.monitor = monitor = lookup(monitor) if isinstance( monitor, basestring) else monitor NUM = count for i in range(NUM): self.watch(DemoClient.using(monitor=monitor), name='client%s' % str(i + 1).rjust(len(str(NUM)), '0'))
def run(self, filename, receiver, checksum=None): if checksum is None: checksum = get_checksum(filename) dbg("checksum:", checksum) if isinstance(receiver, basestring): receiver = lookup(receiver) file = FileRef.publish(filename) receiver << checksum << file import os bytes = os.stat(filename).st_size t1 = time.time() self.watch(receiver) yield self.get(('terminated', receiver)) t2 = time.time() dt = t2 - t1 dbg("%s bytes transferred in %ss -- speed: %r MB/s" % (bytes, dt, round((bytes / dt) / 1024 / 1024, 2)))