@@ -191,7 +191,6 @@ def test_coordination_lock_full_lifecycle_sync(self, driver_sync):
191191 client = CoordinationClient (driver_sync )
192192 node_path = "/local/test_lock_full_lifecycle"
193193
194- # --- cleanup ---
195194 try :
196195 client .delete_node (node_path )
197196 except ydb .SchemeError :
@@ -210,7 +209,6 @@ def test_coordination_lock_full_lifecycle_sync(self, driver_sync):
210209
211210 lock = client .lock ("test_lock" , node_path )
212211
213- # --- create/update/describe ---
214212 create_resp : CreateSemaphoreResult = lock .create (init_limit = 1 , init_data = b"init-data" )
215213 assert create_resp .status == StatusCode .SUCCESS
216214
@@ -222,61 +220,49 @@ def test_coordination_lock_full_lifecycle_sync(self, driver_sync):
222220 assert update_resp .status == StatusCode .SUCCESS
223221 assert lock .describe ().data == b"updated-data"
224222
225- # --- threading coordination ---
226223 lock2_ready = threading .Event ()
227224 lock2_acquired = threading .Event ()
228225 thread_exc = {"err" : None }
229226
230227 def second_lock_task ():
231228 try :
232- lock2_ready .set () # сигнал, что поток готов
229+ lock2_ready .set ()
233230 with client .lock ("test_lock" , node_path ):
234- lock2_acquired .set () # сигнал, что захватил lock
231+ lock2_acquired .set ()
235232 logger .info ("Second thread acquired lock" )
236233 except Exception as e :
237234 logger .exception ("second_lock_task failed" )
238235 thread_exc ["err" ] = e
239236
240237 t2 = threading .Thread (target = second_lock_task )
241238
242- # --- main thread acquires first lock ---
243239 with client .lock ("test_lock" , node_path ) as lock1 :
244240 resp = lock1 .describe ()
245241 assert resp .status == StatusCode .SUCCESS
246242 assert resp .count == 1
247243
248- # запускаем второй поток
249244 t2 .start ()
250245 started = lock2_ready .wait (timeout = 2.0 )
251246 assert started , "Second thread did not signal readiness to acquire lock"
252247
253- # --- main thread released lock, второй поток должен захватить ---
254- acquired = lock2_acquired .wait (timeout = 10.0 ) # увеличенный таймаут
248+ acquired = lock2_acquired .wait (timeout = 10.0 )
255249 t2 .join (timeout = 5.0 )
256250
257251 if not acquired :
258252 if thread_exc ["err" ]:
259253 raise AssertionError (f"Second thread raised exception: { thread_exc ['err' ]!r} " ) from thread_exc ["err" ]
260254 else :
261- raise AssertionError (
262- "Second thread did not acquire the lock in time. Check logs for details."
263- )
255+ raise AssertionError ("Second thread did not acquire the lock in time. Check logs for details." )
264256
265257 assert not t2 .is_alive (), "Second thread did not finish after acquiring lock"
266258
267- # --- проверяем, что lock можно снова взять в главном потоке ---
268259 with client .lock ("test_lock" , node_path ) as lock3 :
269260 resp3 : DescribeLockResult = lock3 .describe ()
270261 assert resp3 .status == StatusCode .SUCCESS
271262 assert resp3 .count == 1
272263
273- # --- cleanup ---
274264 delete_resp = lock .delete ()
275265 assert delete_resp .status == StatusCode .SUCCESS
276- # небольшая пауза для удаления на сервере
277266 time .sleep (0.1 )
278267 describe_after_delete : DescribeLockResult = lock .describe ()
279268 assert describe_after_delete .status == StatusCode .NOT_FOUND
280-
281-
282-
0 commit comments