コード例 #1
0
 def start_client(self):
     self._setup_client()
     self._start_downloads()
     set_exit_handler(self._on_exit)
     
     try:
         while True:
             time.sleep(5)
         time.sleep(self._config.get_report_interval())
     except KeyboardInterrupt:
         pass
     finally:
         self._on_exit()
コード例 #2
0
    def start_client(self):
        self._setup_client()
        self._start_downloads()
        set_exit_handler(self._on_exit)

        try:
            while True:
                time.sleep(5)
            time.sleep(self._config.get_report_interval())
        except KeyboardInterrupt:
            pass
        finally:
            self._on_exit()
コード例 #3
0
ファイル: Cache.py プロジェクト: smoothit/smoothit-client
                    ds['seeds_peers'][0], ds['seeds_peers'][1]))
        print >> sys.stderr,"\n"

def on_exit(signal=None, func=None):
    if not local_reporter == None:
        local_reporter.write_stats()
    logger.warn("Session shutdown")
    session.shutdown()
    logger.warn("wait some time") 
    time.sleep(1) # wait some time so session can stop gracefully
    logger.warn("sys exit (session shutdown takes too long?)")
    sys.exit()

#___________________________________________________________________________________________________
# MAIN
        
if __name__ == '__main__':
    LOG_FILE_NAME = "config/log_iop.conf"
    print "read logging config from file: ", LOG_FILE_NAME
    logging.config.fileConfig(LOG_FILE_NAME)
    
    cache_config = CacheConfiguration()
    cache_config.update_from_cl(sys.argv[1:])
    
    if cache_config.get_logfile() is not None:
        print >>sys.stderr, "Using logfile: %s" % cache_config.get_logfile()    
        common_utils.setup_cache_file_logger(cache_config.get_logfile())
       
    cache = Cache(cache_config)
    Testbed_utils.set_exit_handler(on_exit)
    cache.run_forever()