From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1QMRKC-00070F-Cy for garchives@archives.gentoo.org; Tue, 17 May 2011 20:57:07 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 330971C241; Tue, 17 May 2011 20:56:52 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 0069A1C241 for ; Tue, 17 May 2011 20:56:51 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 956E31B4040 for ; Tue, 17 May 2011 20:56:51 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 0A1F980504 for ; Tue, 17 May 2011 20:56:51 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <0ea4406a64f8af1143e1a819b61f95e8b1777f99.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/tests/locks/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/tests/locks/test_asynchronous_lock.py X-VCS-Directories: pym/portage/tests/locks/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 0ea4406a64f8af1143e1a819b61f95e8b1777f99 Date: Tue, 17 May 2011 20:56:51 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: aafa22c441acfd3b6e25320522e3808d commit: 0ea4406a64f8af1143e1a819b61f95e8b1777f99 Author: Zac Medico gentoo org> AuthorDate: Tue May 17 20:56:15 2011 +0000 Commit: Zac Medico gentoo org> CommitDate: Tue May 17 20:56:15 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3D0ea4406a test_asynchronous_lock: test waiting --- pym/portage/tests/locks/test_asynchronous_lock.py | 25 +++++++++++++++= ++++++ 1 files changed, 25 insertions(+), 0 deletions(-) diff --git a/pym/portage/tests/locks/test_asynchronous_lock.py b/pym/port= age/tests/locks/test_asynchronous_lock.py index 7e9fdfe..e72adf6 100644 --- a/pym/portage/tests/locks/test_asynchronous_lock.py +++ b/pym/portage/tests/locks/test_asynchronous_lock.py @@ -37,3 +37,28 @@ class AsynchronousLockTestCase(TestCase): =20 finally: shutil.rmtree(tempdir) + + def testAsynchronousLockWait(self): + scheduler =3D PollScheduler().sched_iface + tempdir =3D tempfile.mkdtemp() + try: + path =3D os.path.join(tempdir, 'lock_me') + lock1 =3D AsynchronousLock(path=3Dpath, scheduler=3Dscheduler) + lock1.start() + self.assertEqual(lock1.wait(), os.EX_OK) + + # lock2 requires _force_async=3DTrue since the portage.locks + # module is not designed to work as intended here if the + # same process tries to lock the same file more than + # one time concurrently. + lock2 =3D AsynchronousLock(path=3Dpath, scheduler=3Dscheduler, + _force_async=3DTrue, _force_process=3DTrue) + lock2.start() + # lock2 should we waiting for lock1 to release + self.assertEqual(lock2.returncode, None) + + lock1.unlock() + self.assertEqual(lock2.wait(), os.EX_OK) + lock2.unlock() + finally: + shutil.rmtree(tempdir)