def database_changed(sender, **kwargs):
table_name = sender._meta.db_table
if table_name.startswith('chroma_core'): # We are only interested in our tables, not the django ones.
using = kwargs.pop('using', DEFAULT_DB_ALIAS)
if transaction.is_managed(using) is False: # Not a managed transaction so the change has occurred
log.debug('Propagating tablechange for %s' % table_name)
_propagate_table_change([table_name])
else: # This is a transaction and until it commits it has not happened
with operation_lock:
if using not in _pending_table_changes:
log.debug('New transaction change %s using %s' % (table_name, using))
original_commit_fn = transaction.connections[using].commit
original_rollback_fn = transaction.connections[using].rollback
transaction.connections[using].commit = lambda: _transaction_commit_rollback(using,
True,
original_commit_fn,
original_rollback_fn)
transaction.connections[using].rollback = lambda: _transaction_commit_rollback(using,
False,
original_commit_fn,
original_rollback_fn)
log.debug('Adding pending change %s using %s' % (table_name, using))
_pending_table_changes[using].add(table_name)
enable_long_polling.py 文件源码
python
阅读 27
收藏 0
点赞 0
评论 0
评论列表
文章目录