MCPcopy Create free account
hub / github.com/celery/celery / transient_failing_commit

Function transient_failing_commit

t/integration/test_database_backend.py:46–51  ·  view source on GitHub ↗
(self, *args, **kwargs)

Source from the content-addressed store, hash-verified

44 call_count = [0]
45
46 def transient_failing_commit(self, *args, **kwargs):
47 call_count[0] += 1
48 if call_count[0] == 1:
49 # Simulate a network drop or DB disconnect on the first try
50 raise OperationalError("simulated transient DB disconnect", params={}, orig=Exception())
51 return original_commit(self, *args, **kwargs)
52
53 with patch('sqlalchemy.orm.Session.commit', autospec=True, side_effect=transient_failing_commit):
54 # This will trigger the OperationalError, get caught by _ensure_retryable, and retry successfully.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected