<commit_before>import requests
import time
import signal
import sys

from requests_futures.sessions import FuturesSession

import env

ACCOUNT = '<KEY>' #Run 'swift stat' command to see ACCOUNT
CONTAINER = 'DAIKK'
OBJECT = 'admin.sh'


url = 'http://{}:8080/v1/{}/{}/{}'.format(env.IP, ACCOUNT, CONTAINER, OBJECT)

headers = {
  'X-Auth-Token': env.TOKEN
}

fail = 0
success = 0
session = FuturesSession()
tasks = []

def bg_cb(sess, resp):
    print("%d - %s" % (time.time() * 1000, resp.status_code))


def exit_gracefully(signum, frame):
    signal.signal(signal.SIGINT, original_sigint)

    try:
        if raw_input("\nReally quit? (y/n)> ").lower().startswith('y'):
	    for task in tasks:
		print(task.done())
            sys.exit(1)

    except KeyboardInterrupt:
        print("Ok ok, quitting")
        sys.exit(1)

    signal.signal(signal.SIGINT, exit_gracefully)


if __name__ == '__main__':
    original_sigint = signal.getsignal(signal.SIGINT)
    signal.signal(signal.SIGINT, exit_gracefully)

    while(True):
    	time.sleep(0.3)
    	future = session.get(url, headers=headers, background_callback=bg_cb)
	tasks.append(future)
<commit_msg>Format result<commit_after>import requests
import time
import signal
import sys

from requests_futures.sessions import FuturesSession

import env

ACCOUNT = '<KEY>' #Run 'swift stat' command to see ACCOUNT
CONTAINER = 'DAIKK'
OBJECT = 'admin.sh'


url = 'http://{}:8080/v1/{}/{}/{}'.format(env.IP, ACCOUNT, CONTAINER, OBJECT)

headers = {
  'X-Auth-Token': env.TOKEN
}

fail = 0
success = 0
session = FuturesSession()
tasks = []


def bg_cb(sess, resp):
    "Callback function when requests done"

    timestamp = time.time() * 1000
    tasks.append({
        "timestamp": timestamp,
        "status": resp.status_code
    })
    print("%d - %d" % (timestamp, resp.status_code))

def footer():
    "Return result of testing process"

    is_find_start = True
    count = 0
    start, end = 0, 0 # assign this vars prepare if we dont' have downtime

    for task in tasks:
        if is_find_start:
            if task.get('status') >= 400:
                is_find_start = False
                start = task.get('timestamp')
        else:
            count += 1
            if task.get('status') == 200:
                end = task.get('timestamp')
                break

    print("Downtime for rolling upgrade process: {} ms" .format(end-start))
    print("Number of fail requests (status: 503): {}" .format(count))


def exit_gracefully(signum, frame):
    # Source: <NAME> - http://stackoverflow.com/a/18115530
    signal.signal(signal.SIGINT, original_sigint)

    try:
        if raw_input("\nReally quit? (y/n)> ").lower().startswith('y'):
            footer()
            sys.exit(1)

    except KeyboardInterrupt:
        print("Ok ok, quitting")
        sys.exit(1)

    signal.signal(signal.SIGINT, exit_gracefully)


if __name__ == '__main__':
    original_sigint = signal.getsignal(signal.SIGINT)
    signal.signal(signal.SIGINT, exit_gracefully)

    while(True):
    	time.sleep(0.3)
    	future = session.get(url, headers=headers, background_callback=bg_cb)

{'fraction_non_alphanumeric': 0.13546325878594248, 'fraction_numerical': 0.016293929712460065, 'mean_word_length': 2.998722860791826, 'pattern_counts': {'":': 2, '<': 6, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '334152', 'n_tokens_mistral': 1098, 'n_tokens_neox': 1029, 'n_words': 249}