My code, which was running on Sanic version 22.6.0, no longer works on the latest version of Sanic. It’s giving me an error message saying “App instantiation must occur outside if name == ‘main’ block or by using an AppLoader”. According to the documentation, this change was introduced in version 22.9. Sanic now uses an AppLoader
object to create applications in the various worker processes, allowing for a more dynamic startup experience.
Currently, my code uses a create_app
function to create an object, which is then run in an if __name__ == '__main__'
block. However, it seems like this method is no longer supported in the latest version of Sanic. Is it possible for me to keep using my current method, or do I need to switch to using the AppLoader
object?
Thanks