def do_YEP(self, line):
    reactor.callFromThread(on_main_thread, 'YEP')

def do_NOPE(self, line):
    reactor.callFromThread(on_main_thread, 'NOPE')

def on_main_thread(item):
    print('doing', item)

def heartbeat():
    print('heartbeat')
reactor.callLater(1.0, heartbeat)
reactor.callLater(1.0, heartbeat)
reactor.callInThread(CommandProcessor().cmdloop)
reactor.run()
Python Twisted integration with Cmd module