@wrapt.decorator<EOL>def defer_entity_syncing(wrapped, instance, args, kwargs):
<EOL>sync_entities.defer = True<EOL>try:<EOL><INDENT>return wrapped(*args, **kwargs)<EOL><DEDENT>finally:<EOL><INDENT>sync_entities.defer = False<EOL>model_objs = list(sync_entities.buffer.values())<EOL>if None in sync_entities.buffer:<EOL><INDENT>model_objs = list()<EOL><DEDENT>if len(sync_entities.buffer):<EOL><INDENT>sync_entities(*model_objs)<EOL><DEDENT>sync_entities.buffer = {}<EOL><DEDENT>
A decorator that can be used to defer the syncing of entities until after the method has been run
This is being introduced to help avoid deadlocks in the meantime as we attempt to better understand
why they are happening