コード例 #1
0
ファイル: tachyon.py プロジェクト: pdelagrave/tachyon
def wait_for_idle(workers, queue):
    """ Wait until fetch queue is empty and handle user interrupt """
    while len(workers) > 0:
        try:
            if queue.empty():
                # Wait for all threads to return their state
                queue.join()
                for worker in workers:
                    worker.kill_received = True
                workers = []
        except KeyboardInterrupt:
            utils.output_raw('')
            utils.output_info('Keyboard Interrupt Received, cleaning up threads')
            # Kill remaining workers
            for worker in workers:
                worker.kill_received = True
                if worker is not None and worker.isAlive():
                    worker.join(1)

            sys.exit()
コード例 #2
0
ファイル: tachyon.py プロジェクト: pdelagrave/tachyon
    # Spawn synchronized print output worker
    print_worker = PrintWorker()
    print_worker.daemon = True
    print_worker.start()
    
    if conf.debug:
        utils.output_debug('Version: ' + str(conf.version))
        utils.output_debug('Use GET instead of HEAD: ' + str(conf.use_get))
        utils.output_debug('Fetch timeout: ' + str(conf.fetch_timeout_secs))
        utils.output_debug('Max timeouts per url: ' + str(conf.max_timeout_count))
        utils.output_debug('Worker threads: ' + str(conf.thread_count))
        utils.output_debug('Target Host: ' + str(conf.target_host))
        utils.output_debug('Using Tor: ' + str(conf.use_tor))
        utils.output_debug('Content-type Blacklisting: ' + str(conf.content_type_blacklist))
        utils.output_debug('Using User-Agent: ' + str(conf.user_agent))
     
    utils.output_info('Starting Discovery on ' + conf.target_host)

    # Handle keyboard exit before multi-thread operations
    try:
        # Launch main loop
        main()
        # Print all remaining messages
        utils.output_info('Done.\n')
        database.output_queue.join()
    except KeyboardInterrupt:
        utils.output_raw('')
        utils.output_info('Keyboard Interrupt Received')
        database.output_queue.join()
        sys.exit(0)