コード例 #1
0
ファイル: cansina.py プロジェクト: KxCode/cansina
#
# Create the thread_pool and start the daemonized threads
#
thread_pool = []
for visitor_id in range(0, threads):
    v = Visitor(visitor_id, payload_queue, manager)
    thread_pool.append(v)
    v.daemon = True
    v.start()

#
#   Run the main thread until manager exhaust all tasks
#
time_before_running = time.time()
Console.header()

while True:
    try:
        if not manager.get_a_task() and any([visitor.is_alive() for visitor in thread_pool]):
            print("Finishing...")
            break
    except KeyboardInterrupt:
        print (os.linesep + "Waiting for threads to stop...")
        Visitor.kill()
        break

time_after_running = time.time()
delta = round(timedelta(seconds=(time_after_running - time_before_running)).total_seconds(), 2)
print("Task took %i seconds" % delta)
コード例 #2
0
# Select if full path is prefered
full_path = args.full_path

# Select if user wants content-type print
show_content_type = args.show_content_type

#
#   Run the main thread until manager exhaust all tasks
#
time_before_running = time.time()
Console.number_of_requests = payload.get_total_requests()
Console.number_of_threads = threads
Console.start_eta_queue(30)
Console.show_full_path = full_path
Console.show_content_type = show_content_type
Console.header()
Console.set_show_progress(False if args.no_progress else True)
Console.set_show_colors(False if args.no_colors else True)

#
# Create the thread_pool and start the daemonized threads
#
thread_pool = []
for visitor_id in range(threads):
    v = Visitor(visitor_id, payload_queue, manager, manager_lock)
    thread_pool.append(v)
    v.start()

# Main loop
try:
    payload_queue.join()