#NEWLINE# @ skipIf ( ( threading is None ) , 'Test requires threading' ) #NEWLINE# def test_implicit_savepoint_rollback( self ) : #NEWLINE# #INDENT# 'MySQL implicitly rolls back savepoints when it deadlocks (#22291).' #NEWLINE# other_thread_ready = threading . Event ( ) #NEWLINE# def other_thread( ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# with transaction . atomic ( ) : #NEWLINE# #INDENT# Reporter . objects . create ( id = 1 , first_name = 'Tintin' ) #NEWLINE# other_thread_ready . set ( ) #NEWLINE# time . sleep ( 1 ) #NEWLINE# Reporter . objects . exclude ( id = 1 ) . update ( id = 2 ) #NEWLINE# #UNINDENT# #UNINDENT# finally : #NEWLINE# #INDENT# connection . close ( ) #NEWLINE# #UNINDENT# #UNINDENT# other_thread = threading . Thread ( target = other_thread ) #NEWLINE# other_thread . start ( ) #NEWLINE# other_thread_ready . wait ( ) #NEWLINE# with six . assertRaisesRegex ( self , OperationalError , 'Deadlock found' ) : #NEWLINE# #INDENT# with transaction . atomic ( ) : #NEWLINE# #INDENT# with transaction . atomic ( ) : #NEWLINE# #INDENT# Reporter . objects . create ( id = 1 , first_name = 'Tintin' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# other_thread . join ( )