diff --git a/nautobot_chatops/utils.py b/nautobot_chatops/utils.py index c4030761..b2fe8982 100644 --- a/nautobot_chatops/utils.py +++ b/nautobot_chatops/utils.py @@ -22,10 +22,12 @@ class DatabaseSyncToAsync(SyncToAsync): """ SyncToAsync version that cleans up old database connections when it exits. + Sourced from Channels, see NOTICE file for license information. """ def thread_handler(self, loop, *args, **kwargs): + """Run the handler in a thread, closing old database connections before and after.""" close_old_connections() try: return super().thread_handler(loop, *args, **kwargs) @@ -36,6 +38,7 @@ def thread_handler(self, loop, *args, **kwargs): # The class is TitleCased, but we want to encourage use as a callable/decorator database_sync_to_async = DatabaseSyncToAsync + def get_app_config_part(prefix: str) -> dict: """Get part of the app config.