mirror of
https://github.com/ansible/awx.git
synced 2026-03-22 11:25:08 -02:30
close db and cache connection in new threads
This commit is contained in:
@@ -92,6 +92,7 @@ __all__ = [
|
|||||||
'truncate_stdout',
|
'truncate_stdout',
|
||||||
'deepmerge',
|
'deepmerge',
|
||||||
'get_event_partition_epoch',
|
'get_event_partition_epoch',
|
||||||
|
'cleanup_new_process',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@@ -1083,3 +1084,17 @@ def create_partition(tblname, start=None, end=None, partition_label=None, minute
|
|||||||
f'PARTITION OF {tblname} '
|
f'PARTITION OF {tblname} '
|
||||||
f'FOR VALUES FROM (\'{start_timestamp}\') to (\'{end_timestamp}\');'
|
f'FOR VALUES FROM (\'{start_timestamp}\') to (\'{end_timestamp}\');'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def cleanup_new_process(func):
|
||||||
|
"""
|
||||||
|
Cleanup django connection, cache connection, before executing new thread or processes entry point, func.
|
||||||
|
"""
|
||||||
|
|
||||||
|
@wraps(func)
|
||||||
|
def wrapper_cleanup_new_process(*args, **kwargs):
|
||||||
|
django_connection.close()
|
||||||
|
django_cache.close()
|
||||||
|
return func(*args, **kwargs)
|
||||||
|
|
||||||
|
return wrapper_cleanup_new_process
|
||||||
|
|||||||
Reference in New Issue
Block a user