コード例 #1
0
    def testCancelRequest(self):
        resources = []

        def callback(req, res):
            resources.append(res)

        exclusiveReq1 = rm._registerResource(
            "storage", "resource", rm.EXCLUSIVE, callback)
        exclusiveReq2 = rm._registerResource(
            "storage", "resource", rm.EXCLUSIVE, callback)
        exclusiveReq3 = rm._registerResource(
            "storage", "resource", rm.EXCLUSIVE, callback)

        self.assertTrue(exclusiveReq1.granted())
        self.assertFalse(exclusiveReq2.canceled())
        self.assertFalse(exclusiveReq3.granted())

        exclusiveReq2.cancel()
        self.assertTrue(exclusiveReq2.canceled())
        self.assertEqual(resources.pop(), None)  # exclusiveReq 2

        resources.pop().release()  # exclusiveReq 1

        self.assertTrue(exclusiveReq3.granted())
        resources.pop().release()  # exclusiveReq 3
コード例 #2
0
    def testCancelRequest(self, tmp_manager):
        resources = []

        def callback(req, res):
            resources.append(res)

        exclusiveReq1 = rm._registerResource("storage", "resource",
                                             rm.EXCLUSIVE, callback)
        exclusiveReq2 = rm._registerResource("storage", "resource",
                                             rm.EXCLUSIVE, callback)
        exclusiveReq3 = rm._registerResource("storage", "resource",
                                             rm.EXCLUSIVE, callback)

        assert exclusiveReq1.granted()
        assert not exclusiveReq2.canceled()
        assert not exclusiveReq3.granted()

        exclusiveReq2.cancel()
        assert exclusiveReq2.canceled()
        assert resources.pop() is None  # exclusiveReq 2

        resources.pop().release()  # exclusiveReq 1

        assert exclusiveReq3.granted()
        resources.pop().release()  # exclusiveReq 3
コード例 #3
0
    def testRequestRefCmp(self):
        resources = []
        requests = []

        def callback(req, res):
            resources.insert(0, res)
            requests.insert(0, req)

        req1 = rm._registerResource(
            "string", "resource", rm.EXCLUSIVE, callback)
        req2 = rm._registerResource(
            "string", "resource", rm.EXCLUSIVE, callback)

        self.assertNotEqual(req1, req2)
        self.assertEqual(req1, req1)
        self.assertEqual(req2, req2)
        req1.wait()
        req1Clone = requests.pop()
        self.assertEqual(req1, req1Clone)
        self.assertNotEqual(req1Clone, req2)
        resources.pop().release()
        req2.wait()
        req2Clone = requests.pop()
        self.assertEqual(req2, req2Clone)
        self.assertNotEqual(req1, req2Clone)
        self.assertNotEqual(req1Clone, req2Clone)
        resources[0].release()

        self.assertNotEqual(req1, "STUFF")
コード例 #4
0
 def register():
     time.sleep(rnd.randint(0, 4))
     rm._registerResource("string",
                          "resource",
                          lockTranslator[rnd.randint(0, 1)],
                          callback)
     threadLimit.release()
コード例 #5
0
    def testRequestRefCmp(self):
        resources = []
        requests = []

        def callback(req, res):
            resources.insert(0, res)
            requests.insert(0, req)

        req1 = rm._registerResource(
            "string", "resource", rm.EXCLUSIVE, callback)
        req2 = rm._registerResource(
            "string", "resource", rm.EXCLUSIVE, callback)

        self.assertNotEqual(req1, req2)
        self.assertEqual(req1, req1)
        self.assertEqual(req2, req2)
        req1.wait()
        req1Clone = requests.pop()
        self.assertEqual(req1, req1Clone)
        self.assertNotEqual(req1Clone, req2)
        resources.pop().release()
        req2.wait()
        req2Clone = requests.pop()
        self.assertEqual(req2, req2Clone)
        self.assertNotEqual(req1, req2Clone)
        self.assertNotEqual(req1Clone, req2Clone)
        resources[0].release()

        self.assertNotEqual(req1, "STUFF")
コード例 #6
0
 def register():
     time.sleep(rnd.randint(0, 4))
     rm._registerResource("string",
                          "resource",
                          lockTranslator[rnd.randint(0, 1)],
                          callback)
     threadLimit.release()
コード例 #7
0
    def testRequestRefCmp(self):
        resources = []
        requests = []

        def callback(req, res):
            resources.insert(0, res)
            requests.insert(0, req)

        req1 = rm._registerResource("string", "resource", rm.EXCLUSIVE,
                                    callback)
        req2 = rm._registerResource("string", "resource", rm.EXCLUSIVE,
                                    callback)

        assert req1 != req2
        assert req1 == req1
        assert req2 == req2
        req1.wait()
        req1Clone = requests.pop()
        assert req1 == req1Clone
        assert req1Clone != req2
        resources.pop().release()
        req2.wait()
        req2Clone = requests.pop()
        assert req2 == req2Clone
        assert req1 != req2Clone
        assert req1Clone != req2Clone
        resources[0].release()

        assert req1 != "STUFF"
コード例 #8
0
    def testCancelRequest(self):
        resources = []

        def callback(req, res):
            resources.append(res)

        exclusiveReq1 = rm._registerResource(
            "storage", "resource", rm.EXCLUSIVE, callback)
        exclusiveReq2 = rm._registerResource(
            "storage", "resource", rm.EXCLUSIVE, callback)
        exclusiveReq3 = rm._registerResource(
            "storage", "resource", rm.EXCLUSIVE, callback)

        self.assertTrue(exclusiveReq1.granted())
        self.assertFalse(exclusiveReq2.canceled())
        self.assertFalse(exclusiveReq3.granted())

        exclusiveReq2.cancel()
        self.assertTrue(exclusiveReq2.canceled())
        self.assertEqual(resources.pop(), None)  # exclusiveReq 2

        resources.pop().release()  # exclusiveReq 1

        self.assertTrue(exclusiveReq3.granted())
        resources.pop().release()  # exclusiveReq 3
コード例 #9
0
    def testRequestWithBadCallbackOnGrant(self, tmp_manager):
        def callback(req, res):
            res.release()
            raise Exception("BUY MILK!")

        req = rm._registerResource("string", "resource", rm.EXCLUSIVE,
                                   callback)
        req.wait()
コード例 #10
0
    def testRequestWithBadCallbackOnGrant(self):
        def callback(req, res):
            res.release()
            raise Exception("BUY MILK!")

        req = rm._registerResource(
            "string", "resource", rm.EXCLUSIVE, callback)
        req.wait()
コード例 #11
0
    def testCancelExclusiveBetweenShared(self):
        resources = []

        def callback(req, res):
            resources.insert(0, res)

        exclusive1 = rm.acquireResource("string", "resource", rm.EXCLUSIVE)
        sharedReq1 = rm._registerResource(
            "string", "resource", rm.SHARED, callback)
        sharedReq2 = rm._registerResource(
            "string", "resource", rm.SHARED, callback)
        exclusiveReq1 = rm._registerResource(
            "string", "resource", rm.EXCLUSIVE, callback)
        sharedReq3 = rm._registerResource(
            "string", "resource", rm.SHARED, callback)
        sharedReq4 = rm._registerResource(
            "string", "resource", rm.SHARED, callback)

        self.assertFalse(sharedReq1.granted())
        self.assertFalse(sharedReq2.granted())
        self.assertFalse(exclusiveReq1.granted())
        self.assertFalse(sharedReq3.granted())
        self.assertFalse(sharedReq4.granted())

        exclusiveReq1.cancel()
        resources.pop()

        self.assertFalse(sharedReq1.granted())
        self.assertFalse(sharedReq2.granted())
        self.assertFalse(exclusiveReq1.granted())
        self.assertTrue(exclusiveReq1.canceled())
        self.assertFalse(sharedReq3.granted())
        self.assertFalse(sharedReq4.granted())

        exclusive1.release()
        self.assertTrue(sharedReq1.granted())
        self.assertTrue(sharedReq2.granted())
        self.assertTrue(sharedReq3.granted())
        self.assertTrue(sharedReq4.granted())

        while len(resources) > 0:
            resources.pop().release()
コード例 #12
0
    def testCancelExclusiveBetweenShared(self, tmp_manager):
        resources = []

        def callback(req, res):
            resources.insert(0, res)

        exclusive1 = rm.acquireResource("string", "resource", rm.EXCLUSIVE)
        sharedReq1 = rm._registerResource("string", "resource", rm.SHARED,
                                          callback)
        sharedReq2 = rm._registerResource("string", "resource", rm.SHARED,
                                          callback)
        exclusiveReq1 = rm._registerResource("string", "resource",
                                             rm.EXCLUSIVE, callback)
        sharedReq3 = rm._registerResource("string", "resource", rm.SHARED,
                                          callback)
        sharedReq4 = rm._registerResource("string", "resource", rm.SHARED,
                                          callback)

        assert not sharedReq1.granted()
        assert not sharedReq2.granted()
        assert not exclusiveReq1.granted()
        assert not sharedReq3.granted()
        assert not sharedReq4.granted()

        exclusiveReq1.cancel()
        resources.pop()

        assert not sharedReq1.granted()
        assert not sharedReq2.granted()
        assert not exclusiveReq1.granted()
        assert exclusiveReq1.canceled()
        assert not sharedReq3.granted()
        assert not sharedReq4.granted()

        exclusive1.release()
        assert sharedReq1.granted()
        assert sharedReq2.granted()
        assert sharedReq3.granted()
        assert sharedReq4.granted()

        while len(resources) > 0:
            resources.pop().release()
コード例 #13
0
    def testRequestWithBadCallbackOnCancel(self, tmp_manager):
        def callback(req, res):
            raise Exception("BUY MILK!")

        blocker = rm.acquireResource("string", "resource", rm.EXCLUSIVE)
        req = rm._registerResource("string", "resource", rm.EXCLUSIVE,
                                   callback)

        req.cancel()

        blocker.release()
コード例 #14
0
    def testRequestWithBadCallbackOnCancel(self):
        def callback(req, res):
            raise Exception("BUY MILK!")

        blocker = rm.acquireResource("string", "resource", rm.EXCLUSIVE)
        req = rm._registerResource(
            "string", "resource", rm.EXCLUSIVE, callback)

        req.cancel()

        blocker.release()
コード例 #15
0
    def testRequestRefStr(self):
        resources = []

        def callback(req, res):
            resources.insert(0, res)

        req = rm._registerResource("string", "resource", rm.SHARED, callback)
        try:
            str(req)
        finally:
            req.wait()
            resources[0].release()
コード例 #16
0
    def testRequestRefStr(self, tmp_manager):
        resources = []

        def callback(req, res):
            resources.insert(0, res)

        req = rm._registerResource("string", "resource", rm.SHARED, callback)
        try:
            str(req)
        finally:
            req.wait()
            resources[0].release()
コード例 #17
0
ファイル: resourcemanager_test.py プロジェクト: xin49/vdsm
    def testResourceLockSwitch(self, namespace="string"):
        resources = []

        def callback(req, res):
            resources.insert(0, res)

        exclusive1 = rm.acquireResource(namespace, "resource", rm.EXCLUSIVE)
        sharedReq1 = rm._registerResource(namespace, "resource", rm.SHARED,
                                          callback)
        sharedReq2 = rm._registerResource(namespace, "resource", rm.SHARED,
                                          callback)
        exclusive2 = rm._registerResource(namespace, "resource", rm.EXCLUSIVE,
                                          callback)
        exclusive3 = rm._registerResource(namespace, "resource", rm.EXCLUSIVE,
                                          callback)
        sharedReq3 = rm._registerResource(namespace, "resource", rm.SHARED,
                                          callback)

        self.assertEqual(exclusive1.read(), "resource:exclusive")
        exclusive1.release()
        self.assertEqual(resources[-1].read(), "resource:shared")
        resources.pop().release()
        self.assertEqual(resources[-1].read(), "")
        resources.pop().release()
        self.assertEqual(resources[-1].read(), "resource:exclusive")
        resources.pop().release()
        self.assertEqual(resources[-1].read(), "")
        resources.pop().release()
        self.assertEqual(resources[-1].read(), "resource:shared")
        resources.pop().release()
        # This part is to stop pyflakes for complaining, the reason I need the
        # resourcesRefs alive is so that the manage will not autocollect during
        # the test
        hash(sharedReq1)
        hash(sharedReq2)
        hash(sharedReq3)
        hash(exclusive2)
        hash(exclusive3)
        hash(sharedReq3)
コード例 #18
0
    def testFailCreateAfterSwitch(self):
        resources = []

        def callback(req, res):
            resources.append(res)

        exclusive1 = rm.acquireResource(
            "failAfterSwitch", "resource", rm.EXCLUSIVE)
        sharedReq1 = rm._registerResource(
            "failAfterSwitch", "resource", rm.SHARED, callback)
        exclusive1.release()
        self.assertTrue(sharedReq1.canceled())
        self.assertEqual(resources[0], None)
コード例 #19
0
    def testResourceLockSwitch(self, namespace="string"):
        resources = []

        def callback(req, res):
            resources.insert(0, res)

        exclusive1 = rm.acquireResource(namespace, "resource", rm.EXCLUSIVE)
        sharedReq1 = rm._registerResource(
            namespace, "resource", rm.SHARED, callback)
        sharedReq2 = rm._registerResource(
            namespace, "resource", rm.SHARED, callback)
        exclusive2 = rm._registerResource(
            namespace, "resource", rm.EXCLUSIVE, callback)
        exclusive3 = rm._registerResource(
            namespace, "resource", rm.EXCLUSIVE, callback)
        sharedReq3 = rm._registerResource(
            namespace, "resource", rm.SHARED, callback)

        self.assertEqual(exclusive1.read(), "resource:exclusive")
        exclusive1.release()
        self.assertEqual(resources[-1].read(), "resource:shared")
        resources.pop().release()
        self.assertEqual(resources[-1].read(), "")
        resources.pop().release()
        self.assertEqual(resources[-1].read(), "resource:exclusive")
        resources.pop().release()
        self.assertEqual(resources[-1].read(), "")
        resources.pop().release()
        self.assertEqual(resources[-1].read(), "resource:shared")
        resources.pop().release()
        # This part is to stop pyflakes for complaining, the reason I need the
        # resourcesRefs alive is so that the manage will not autocollect during
        # the test
        hash(sharedReq1)
        hash(sharedReq2)
        hash(sharedReq3)
        hash(exclusive2)
        hash(exclusive3)
        hash(sharedReq3)
コード例 #20
0
    def testFailCreateAfterSwitch(self):
        resources = []

        def callback(req, res):
            resources.append(res)

        exclusive1 = rm.acquireResource(
            "failAfterSwitch", "resource", rm.EXCLUSIVE)
        sharedReq1 = rm._registerResource(
            "failAfterSwitch", "resource", rm.SHARED, callback)
        exclusive1.release()
        self.assertTrue(sharedReq1.canceled())
        self.assertEqual(resources[0], None)
コード例 #21
0
    def testAccessAttributeNotExposedByRequestRef(self, tmp_manager):
        resources = []

        def callback(req, res):
            resources.insert(0, res)

        req = rm._registerResource("string", "resource", rm.SHARED, callback)
        with pytest.raises(AttributeError):
            try:
                req.grant()
            finally:
                req.wait()
                resources[0].release()
コード例 #22
0
    def testFailCreateAfterSwitch(self, tmp_manager):
        resources = []

        def callback(req, res):
            resources.append(res)

        exclusive1 = rm.acquireResource("failAfterSwitch", "resource",
                                        rm.EXCLUSIVE)
        sharedReq1 = rm._registerResource("failAfterSwitch", "resource",
                                          rm.SHARED, callback)
        exclusive1.release()
        assert sharedReq1.canceled()
        assert resources[0] is None
コード例 #23
0
    def testAcquireResourceExclusive(self, tmp_manager):
        resources = []

        def callback(req, res):
            resources.append(res)

        exclusive1 = rm.acquireResource("storage", "resource", rm.EXCLUSIVE)
        sharedReq1 = rm._registerResource("storage", "resource", rm.SHARED,
                                          callback)
        sharedReq2 = rm._registerResource("storage", "resource", rm.SHARED,
                                          callback)
        exclusiveReq1 = rm._registerResource("storage", "resource",
                                             rm.EXCLUSIVE, callback)
        exclusiveReq2 = rm._registerResource("storage", "resource",
                                             rm.EXCLUSIVE, callback)

        assert not sharedReq1.granted()
        assert not sharedReq2.granted()
        assert not exclusiveReq1.granted()
        assert not exclusiveReq2.granted()
        exclusive1.release()

        assert sharedReq1.granted()
        assert sharedReq2.granted()
        assert not exclusiveReq1.granted()
        assert not exclusiveReq2.granted()
        resources.pop().release()  # Shared 1

        assert not exclusiveReq1.granted()
        assert not exclusiveReq2.granted()
        resources.pop().release()  # Shared 2

        assert exclusiveReq1.granted()
        assert not exclusiveReq2.granted()
        resources.pop().release()  # exclusiveReq 1

        assert exclusiveReq2.granted()
        resources.pop().release()  # exclusiveReq 2
コード例 #24
0
    def testAcquireResourceExclusive(self):
        resources = []

        def callback(req, res):
            resources.append(res)

        exclusive1 = rm.acquireResource("storage", "resource", rm.EXCLUSIVE)
        sharedReq1 = rm._registerResource(
            "storage", "resource", rm.SHARED, callback)
        sharedReq2 = rm._registerResource(
            "storage", "resource", rm.SHARED, callback)
        exclusiveReq1 = rm._registerResource(
            "storage", "resource", rm.EXCLUSIVE, callback)
        exclusiveReq2 = rm._registerResource(
            "storage", "resource", rm.EXCLUSIVE, callback)

        self.assertFalse(sharedReq1.granted())
        self.assertFalse(sharedReq2.granted())
        self.assertFalse(exclusiveReq1.granted())
        self.assertFalse(exclusiveReq2.granted())
        exclusive1.release()

        self.assertTrue(sharedReq1.granted())
        self.assertTrue(sharedReq2.granted())
        self.assertFalse(exclusiveReq1.granted())
        self.assertFalse(exclusiveReq2.granted())
        resources.pop().release()  # Shared 1

        self.assertFalse(exclusiveReq1.granted())
        self.assertFalse(exclusiveReq2.granted())
        resources.pop().release()  # Shared 2

        self.assertTrue(exclusiveReq1.granted())
        self.assertFalse(exclusiveReq2.granted())
        resources.pop().release()  # exclusiveReq 1

        self.assertTrue(exclusiveReq2.granted())
        resources.pop().release()  # exclusiveReq 2
コード例 #25
0
    def testAcquireResourceExclusive(self):
        resources = []

        def callback(req, res):
            resources.append(res)

        exclusive1 = rm.acquireResource("storage", "resource", rm.EXCLUSIVE)
        sharedReq1 = rm._registerResource(
            "storage", "resource", rm.SHARED, callback)
        sharedReq2 = rm._registerResource(
            "storage", "resource", rm.SHARED, callback)
        exclusiveReq1 = rm._registerResource(
            "storage", "resource", rm.EXCLUSIVE, callback)
        exclusiveReq2 = rm._registerResource(
            "storage", "resource", rm.EXCLUSIVE, callback)

        self.assertFalse(sharedReq1.granted())
        self.assertFalse(sharedReq2.granted())
        self.assertFalse(exclusiveReq1.granted())
        self.assertFalse(exclusiveReq2.granted())
        exclusive1.release()

        self.assertTrue(sharedReq1.granted())
        self.assertTrue(sharedReq2.granted())
        self.assertFalse(exclusiveReq1.granted())
        self.assertFalse(exclusiveReq2.granted())
        resources.pop().release()  # Shared 1

        self.assertFalse(exclusiveReq1.granted())
        self.assertFalse(exclusiveReq2.granted())
        resources.pop().release()  # Shared 2

        self.assertTrue(exclusiveReq1.granted())
        self.assertFalse(exclusiveReq2.granted())
        resources.pop().release()  # exclusiveReq 1

        self.assertTrue(exclusiveReq2.granted())
        resources.pop().release()  # exclusiveReq 2
コード例 #26
0
    def testResourceLockSwitch(self, namespace, tmp_manager):
        resources = []

        def callback(req, res):
            resources.insert(0, res)

        exclusive1 = rm.acquireResource(namespace, "resource", rm.EXCLUSIVE)
        sharedReq1 = rm._registerResource(namespace, "resource", rm.SHARED,
                                          callback)
        sharedReq2 = rm._registerResource(namespace, "resource", rm.SHARED,
                                          callback)
        exclusive2 = rm._registerResource(namespace, "resource", rm.EXCLUSIVE,
                                          callback)
        exclusive3 = rm._registerResource(namespace, "resource", rm.EXCLUSIVE,
                                          callback)
        sharedReq3 = rm._registerResource(namespace, "resource", rm.SHARED,
                                          callback)

        assert exclusive1.read() == "resource:exclusive"
        exclusive1.release()
        assert resources[-1].read() == "resource:shared"
        resources.pop().release()
        assert resources[-1].read() == ""
        resources.pop().release()
        assert resources[-1].read() == "resource:exclusive"
        resources.pop().release()
        assert resources[-1].read() == ""
        resources.pop().release()
        assert resources[-1].read() == "resource:shared"
        resources.pop().release()

        # Silense flake8 unused local variables warnings.
        sharedReq1
        sharedReq2
        exclusive2
        exclusive3
        sharedReq3
コード例 #27
0
    def testResourceLockSwitch(self, namespace="string"):
        resources = []

        def callback(req, res):
            resources.insert(0, res)

        exclusive1 = rm.acquireResource(namespace, "resource", rm.EXCLUSIVE)
        sharedReq1 = rm._registerResource(
            namespace, "resource", rm.SHARED, callback)
        sharedReq2 = rm._registerResource(
            namespace, "resource", rm.SHARED, callback)
        exclusive2 = rm._registerResource(
            namespace, "resource", rm.EXCLUSIVE, callback)
        exclusive3 = rm._registerResource(
            namespace, "resource", rm.EXCLUSIVE, callback)
        sharedReq3 = rm._registerResource(
            namespace, "resource", rm.SHARED, callback)

        self.assertEqual(exclusive1.read(), "resource:exclusive")
        exclusive1.release()
        self.assertEqual(resources[-1].read(), "resource:shared")
        resources.pop().release()
        self.assertEqual(resources[-1].read(), "")
        resources.pop().release()
        self.assertEqual(resources[-1].read(), "resource:exclusive")
        resources.pop().release()
        self.assertEqual(resources[-1].read(), "")
        resources.pop().release()
        self.assertEqual(resources[-1].read(), "resource:shared")
        resources.pop().release()

        # Silense flake8 unused local variables warnings.
        sharedReq1
        sharedReq2
        exclusive2
        exclusive3
        sharedReq3
コード例 #28
0
    def testRequestRecancel(self):
        resources = []

        def callback(req, res):
            resources.insert(0, res)

        blocker = rm.acquireResource("string", "resource", rm.EXCLUSIVE)
        req = rm._registerResource(
            "string", "resource", rm.EXCLUSIVE, callback)

        req.cancel()

        self.assertRaises(rm.RequestAlreadyProcessedError, req.cancel)

        blocker.release()
コード例 #29
0
    def testRequestRecancel(self):
        resources = []

        def callback(req, res):
            resources.insert(0, res)

        blocker = rm.acquireResource("string", "resource", rm.EXCLUSIVE)
        req = rm._registerResource(
            "string", "resource", rm.EXCLUSIVE, callback)

        req.cancel()

        self.assertRaises(rm.RequestAlreadyProcessedError, req.cancel)

        blocker.release()
コード例 #30
0
    def testAccessAttributeNotExposedByRequestRef(self):
        resources = []

        def callback(req, res):
            resources.insert(0, res)

        req = rm._registerResource("string", "resource", rm.SHARED, callback)
        with pytest.raises(
                AttributeError,
                message="Managed to access an attribute not exposed by wrapper"
        ):
            try:
                req.grant()
            finally:
                req.wait()
                resources[0].release()
コード例 #31
0
    def testAccessAttributeNotExposedByRequestRef(self):
        resources = []

        def callback(req, res):
            resources.insert(0, res)

        req = rm._registerResource("string", "resource", rm.SHARED, callback)
        try:
            req.grant()
        except AttributeError:
            return
        except Exception as ex:
            self.fail("Wrong exception was raised. "
                      "Expected AttributeError got %s", ex.__class__.__name__)
        finally:
            req.wait()
            resources[0].release()

        self.fail("Managed to access an attribute not exposed by wrapper")
コード例 #32
0
    def testAccessAttributeNotExposedByRequestRef(self):
        resources = []

        def callback(req, res):
            resources.insert(0, res)

        req = rm._registerResource("string", "resource", rm.SHARED, callback)
        try:
            req.grant()
        except AttributeError:
            return
        except Exception as ex:
            self.fail("Wrong exception was raised. "
                      "Expected AttributeError got %s", ex.__class__.__name__)
        finally:
            req.wait()
            resources[0].release()

        self.fail("Managed to access an attribute not exposed by wrapper")
コード例 #33
0
 def testErrorInFactory(self):
     req = rm._registerResource(
         "error", "resource", rm.EXCLUSIVE, lambda req, res: 1)
     self.assertTrue(req.canceled())
コード例 #34
0
 def testErrorInFactory(self, tmp_manager):
     req = rm._registerResource("error", "resource", rm.EXCLUSIVE,
                                lambda req, res: 1)
     assert req.canceled()
コード例 #35
0
 def testErrorInFactory(self):
     req = rm._registerResource(
         "error", "resource", rm.EXCLUSIVE, lambda req, res: 1)
     self.assertTrue(req.canceled())