def thing1():
    print('Doing thing 1')
reactor.do(thing2)
reactor.do(thing3)

def thing2():
    print('Doing thing 2')

def thing3():
    print('Doing thing 3: and stopping')
reactor.stop()
reactor.do(thing1)
print('Running')
reactor.run()
print('Done!')
Asychronous Programming in Python Twisted