0

Say I have some function defined using Python3 tornado's async functions

@gen.coroutine
def translateSimple(toTranslate, commands):
    proc_in, proc_out = startPipeline(commands)
    yield gen.Task(proc_in.stdin.write, bytes(toTranslate, 'utf-8'))
    proc_in.stdin.close()
    translated = yield gen.Task(proc_out.stdout.read_until_close)
    proc_in.stdout.close()
    return translated.decode('utf-8')

– this runs fine as part of a tornado http server etc., but how would I run just this one function from the REPL (having the REPL block/wait until it's done, as if it were not async) to do debugging?

unhammer
  • 4,306
  • 2
  • 39
  • 52

1 Answers1

0

Found it as I was writing:

tornado.ioloop.IOLoop.instance().run_sync(lambda: translateSimple(text, cmds))
unhammer
  • 4,306
  • 2
  • 39
  • 52