You get a similar interface in Python's Twisted using the @inlineCallbacks decorator:
@inlineCallbacks
def example():
try:
obtain_some_lock()
ui_status("Fetching file...")
result = yield fetch_file_from_server(args)
ui_status("Uploading file...")
yield post_file_to_other_server(result)
ui_status("Done.")
except SomeError as e:
ui_status("Error: %s" % e.msg)
finally:
release_some_lock()
I must say that this style of writing async code is much friendlier than descending into callback hell.There is work to make a similar async interface native in Python 3, in PEP 3156 http://www.python.org/dev/peps/pep-3156/, so this should become more widely available even to those who don't use Twisted.