lock()) { try { // do stuff ... $my_lock_again = new Updraft_Semaphore_3_0('my_test_lock_name', 4, array(new Test_Logger_2())); $time_now = microtime(true); if ($my_lock_again->lock(6)) { echo "Eventually got it after ".round(microtime(true) - $time_now, 3)." seconds\n"; $my_lock_again->release(); } else { echo("Sorry, could not get the second lock\n"); } } catch (Exception $e) { var_dump($e); // We are making sure we release the lock in case of an error } catch (Error $e) { // phpcs:ignore PHPCompatibility.Classes.NewClasses.errorFound var_dump($e); // We are making sure we release the lock in case of an error } $my_lock->release(); } else { echo("Sorry, could not get the first lock\n"); }