would like a infinite retry. but infinite is too scaring while counter < 1000: counter += 1 try: with transaction.atomic(): cursor = connections[‘your_db’].cursor() cursor.execute('SET TRANSACTION ISOLATION LEVEL SERIALIZABLE') # Your DB Operations except OperationalError: time.sleep(counter) # to avoid retry in a very short interval continue 1 2 3 3 latter transaction will meets Operational Error, usually it needs retry