edgi-govdata-archiving/web-monitoring-processing

Use Python native async syntax in diff server

Mr0grog opened this issue · 0 comments

In the diffing server, we use Tornado, which existed before asyncio and has specialized decorators for creating coroutines. Since version 5 (which we are on, and we are ready to upgrade to 6), it’s not only had support for the new native Python async syntax, but Tornado devs encourage its use and are deprecating some of the async features Tornado duplicates.

This is great! But we definitely should upgrade our code to use the new native syntax now that it’s well supported.

I’m reasonably certain these changes are confined to:

  • web_monitoring/diffing_server.py
  • web_monitoring/tests/test_diffing_server_exc_handling.py

And involve replacing code like:

# Old-style, non-native:
@tornado.gen.coroutine
def some_function(x, y, z):
    ...
    result = yield some_async_function(x)
    ...
    raise tornado.gen.Return(return_value)

# New, native async style:
async some_function(x, y, z):
    ...
    result = await some_async_function(x)
    ...
    return return_value