signal.signal(signal.SIGINT, stop_handler)
running = True
state_filename = 'state.txt'
if os.path.isfile(state_filename):
    with open(state_filename, 'rb') as f_state:
        my_state = cPickle.load(f_state)
else:
    my_state = MyState()
while running:
    print(my_state.count)
my_state.count += 1
with open(state_filename, 'wb') as f_state:
    cPickle.dump(my_state, f_state)
Prime number hard drive storage for very large primes - Sieve of Atkin