mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-22 04:11:09 -05:00
okay fine
This commit is contained in:
19
.venv/lib/python3.12/site-packages/channels/db.py
Normal file
19
.venv/lib/python3.12/site-packages/channels/db.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from asgiref.sync import SyncToAsync
|
||||
from django.db import close_old_connections
|
||||
|
||||
|
||||
class DatabaseSyncToAsync(SyncToAsync):
|
||||
"""
|
||||
SyncToAsync version that cleans up old database connections when it exits.
|
||||
"""
|
||||
|
||||
def thread_handler(self, loop, *args, **kwargs):
|
||||
close_old_connections()
|
||||
try:
|
||||
return super().thread_handler(loop, *args, **kwargs)
|
||||
finally:
|
||||
close_old_connections()
|
||||
|
||||
|
||||
# The class is TitleCased, but we want to encourage use as a callable/decorator
|
||||
database_sync_to_async = DatabaseSyncToAsync
|
||||
Reference in New Issue
Block a user