当前位置: 首页>>代码示例>>Python>>正文


Python persistence_utils.temporary_log_book函数代码示例

本文整理汇总了Python中taskflow.utils.persistence_utils.temporary_log_book函数的典型用法代码示例。如果您正苦于以下问题:Python temporary_log_book函数的具体用法?Python temporary_log_book怎么用?Python temporary_log_book使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了temporary_log_book函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_posting_consume_wait

 def test_posting_consume_wait(self):
     with connect_close(self.board):
         jb = self.board.post('test', p_utils.temporary_log_book())
         possible_jobs = list(self.board.iterjobs(only_unclaimed=True))
         self.board.claim(possible_jobs[0], self.board.name)
         self.board.consume(possible_jobs[0], self.board.name)
         self.assertTrue(jb.wait())
开发者ID:HoratiusTang,项目名称:taskflow,代码行数:7,代码来源:base.py

示例2: test_trashing_claimed_job

    def test_trashing_claimed_job(self):

        with base.connect_close(self.board):
            with base.flush(self.client):
                j = self.board.post('test', p_utils.temporary_log_book())
            self.assertEqual(states.UNCLAIMED, j.state)
            with base.flush(self.client):
                self.board.claim(j, self.board.name)
            self.assertEqual(states.CLAIMED, j.state)

            with base.flush(self.client):
                self.board.trash(j, self.board.name)

            trashed = []
            jobs = []
            paths = list(six.iteritems(self.client.storage.paths))
            for (path, value) in paths:
                if path in self.bad_paths:
                    continue
                if path.find(impl_zookeeper.TRASH_FOLDER) > -1:
                    trashed.append(path)
                elif (path.find(self.board._job_base) > -1
                        and not path.endswith(impl_zookeeper.LOCK_POSTFIX)):
                    jobs.append(path)

            self.assertEqual(len(trashed), 1)
            self.assertEqual(len(jobs), 0)
开发者ID:Dynavisor,项目名称:taskflow,代码行数:27,代码来源:test_zk_job.py

示例3: test_posting_no_post

 def test_posting_no_post(self):
     with base.connect_close(self.board):
         with mock.patch.object(self.client, 'create') as create_func:
             create_func.side_effect = IOError("Unable to post")
             self.assertRaises(IOError, self.board.post,
                               'test', p_utils.temporary_log_book())
         self.assertEqual(0, self.board.job_count)
开发者ID:jimbobhickville,项目名称:taskflow,代码行数:7,代码来源:test_zk_job.py

示例4: test_posting_received_raw

    def test_posting_received_raw(self):
        book = p_utils.temporary_log_book()

        with base.connect_close(self.board):
            self.assertTrue(self.board.connected)
            self.assertEqual(0, self.board.job_count)
            posted_job = self.board.post('test', book)

            self.assertEqual(self.board, posted_job.board)
            self.assertEqual(1, self.board.job_count)
            self.assertIn(posted_job.uuid, [j.uuid
                                            for j in self.board.iterjobs()])

        # Remove paths that got created due to the running process that we are
        # not interested in...
        paths = {}
        for (path, data) in six.iteritems(self.client.storage.paths):
            if path in self.bad_paths:
                continue
            paths[path] = data

        # Check the actual data that was posted.
        self.assertEqual(1, len(paths))
        path_key = list(six.iterkeys(paths))[0]
        self.assertTrue(len(paths[path_key]['data']) > 0)
        self.assertDictEqual({
            'uuid': posted_job.uuid,
            'name': posted_job.name,
            'book': {
                'name': book.name,
                'uuid': book.uuid,
            },
            'details': {},
        }, jsonutils.loads(misc.binary_decode(paths[path_key]['data'])))
开发者ID:Dynavisor,项目名称:taskflow,代码行数:34,代码来源:test_zk_job.py

示例5: test_posting_dates

    def test_posting_dates(self, mock_dt):
        epoch = misc.millis_to_datetime(0)
        mock_dt.return_value = epoch

        with base.connect_close(self.board):
            j = self.board.post('test', p_utils.temporary_log_book())
            self.assertEqual(epoch, j.created_on)
            self.assertEqual(epoch, j.last_modified)

        self.assertTrue(mock_dt.called)
开发者ID:jimbobhickville,项目名称:taskflow,代码行数:10,代码来源:test_zk_job.py

示例6: test_posting_abandon_no_owner

    def test_posting_abandon_no_owner(self):

        with connect_close(self.board):
            with flush(self.client):
                self.board.post('test', p_utils.temporary_log_book())

            self.assertEqual(1, self.board.job_count)
            possible_jobs = list(self.board.iterjobs(only_unclaimed=True))
            self.assertEqual(1, len(possible_jobs))
            j = possible_jobs[0]
            self.assertRaises(excp.JobFailure, self.board.abandon, j, j.name)
开发者ID:zhxqgithub,项目名称:taskflow,代码行数:11,代码来源:base.py

示例7: test_posting_claim_diff_owner

    def test_posting_claim_diff_owner(self):

        with connect_close(self.board):
            with self.flush(self.client):
                self.board.post("test", p_utils.temporary_log_book())

            possible_jobs = list(self.board.iterjobs(only_unclaimed=True))
            self.assertEqual(1, len(possible_jobs))
            with self.flush(self.client):
                self.board.claim(possible_jobs[0], self.board.name)

            possible_jobs = list(self.board.iterjobs())
            self.assertEqual(1, len(possible_jobs))
            self.assertRaises(excp.UnclaimableJob, self.board.claim, possible_jobs[0], self.board.name + "-1")
            possible_jobs = list(self.board.iterjobs(only_unclaimed=True))
            self.assertEqual(0, len(possible_jobs))
开发者ID:junneyang,项目名称:taskflow,代码行数:16,代码来源:base.py

示例8: test_posting_claim_abandon

    def test_posting_claim_abandon(self):

        with connect_close(self.board):
            with self.flush(self.client):
                self.board.post('test', p_utils.temporary_log_book())

            possible_jobs = list(self.board.iterjobs(only_unclaimed=True))
            self.assertEqual(1, len(possible_jobs))
            j = possible_jobs[0]
            with self.flush(self.client):
                self.board.claim(j, self.board.name)

            possible_jobs = list(self.board.iterjobs(only_unclaimed=True))
            self.assertEqual(0, len(possible_jobs))
            with self.flush(self.client):
                self.board.abandon(j, self.board.name)

            possible_jobs = list(self.board.iterjobs(only_unclaimed=True))
            self.assertEqual(1, len(possible_jobs))
开发者ID:HoratiusTang,项目名称:taskflow,代码行数:19,代码来源:base.py

示例9: test_posting_claim_consume

    def test_posting_claim_consume(self):

        with connect_close(self.board):
            with self.flush(self.client):
                self.board.post("test", p_utils.temporary_log_book())

            possible_jobs = list(self.board.iterjobs(only_unclaimed=True))
            self.assertEqual(1, len(possible_jobs))
            j = possible_jobs[0]
            with self.flush(self.client):
                self.board.claim(j, self.board.name)

            possible_jobs = list(self.board.iterjobs(only_unclaimed=True))
            self.assertEqual(0, len(possible_jobs))
            with self.flush(self.client):
                self.board.consume(j, self.board.name)

            self.assertEqual(0, len(list(self.board.iterjobs())))
            self.assertRaises(excp.NotFound, self.board.consume, j, self.board.name)
开发者ID:junneyang,项目名称:taskflow,代码行数:19,代码来源:base.py

示例10: test_posting_state_lock_lost

    def test_posting_state_lock_lost(self):

        with base.connect_close(self.board):
            with base.flush(self.client):
                j = self.board.post('test', p_utils.temporary_log_book())
            self.assertEqual(states.UNCLAIMED, j.state)
            with base.flush(self.client):
                self.board.claim(j, self.board.name)
            self.assertEqual(states.CLAIMED, j.state)

            # Forcefully delete the lock from the backend storage to make
            # sure the job becomes unclaimed (this may happen if some admin
            # manually deletes the lock).
            paths = list(six.iteritems(self.client.storage.paths))
            for (path, value) in paths:
                if path in self.bad_paths:
                    continue
                if path.endswith("lock"):
                    self.client.storage.pop(path)
            self.assertEqual(states.UNCLAIMED, j.state)
开发者ID:Dynavisor,项目名称:taskflow,代码行数:20,代码来源:test_zk_job.py

示例11: test_posting_owner_lost

    def test_posting_owner_lost(self):

        with connect_close(self.board):
            j = self.board.post('test', p_utils.temporary_log_book())
            self.client.flush()
            self.assertEqual(states.UNCLAIMED, j.state)
            self.board.claim(j, self.board.name)
            self.client.flush()
            self.assertEqual(states.CLAIMED, j.state)

            # Forcefully delete the owner from the backend storage to make
            # sure the job becomes unclaimed (this may happen if some admin
            # manually deletes the lock).
            paths = list(six.iteritems(self.client.storage.paths))
            for (path, value) in paths:
                if path in self.bad_paths:
                    continue
                if path.endswith('lock'):
                    value['data'] = misc.binary_encode(jsonutils.dumps({}))
            self.assertEqual(states.UNCLAIMED, j.state)
开发者ID:varunarya10,项目名称:taskflow,代码行数:20,代码来源:test_zk_job.py

示例12: test_posting_claim_same_owner

    def test_posting_claim_same_owner(self):
        with base.connect_close(self.board):
            with self.flush(self.client):
                self.board.post('test', p_utils.temporary_log_book())

            self.assertEqual(1, self.board.job_count)
            possible_jobs = list(self.board.iterjobs(only_unclaimed=True))
            self.assertEqual(1, len(possible_jobs))
            j = possible_jobs[0]
            self.assertEqual(states.UNCLAIMED, j.state)

            with self.flush(self.client):
                self.board.claim(j, self.board.name)

            possible_jobs = list(self.board.iterjobs())
            self.assertEqual(1, len(possible_jobs))
            with self.flush(self.client):
                self.assertRaises(excp.UnclaimableJob, self.board.claim,
                                  possible_jobs[0], self.board.name)
            possible_jobs = list(self.board.iterjobs(only_unclaimed=True))
            self.assertEqual(0, len(possible_jobs))
开发者ID:jimbobhickville,项目名称:taskflow,代码行数:21,代码来源:test_redis_job.py

示例13: test_posting_claim_expiry

    def test_posting_claim_expiry(self):

        with base.connect_close(self.board):
            with self.flush(self.client):
                self.board.post('test', p_utils.temporary_log_book())

            self.assertEqual(1, self.board.job_count)
            possible_jobs = list(self.board.iterjobs(only_unclaimed=True))
            self.assertEqual(1, len(possible_jobs))
            j = possible_jobs[0]
            self.assertEqual(states.UNCLAIMED, j.state)

            with self.flush(self.client):
                self.board.claim(j, self.board.name, expiry=0.5)

            self.assertEqual(self.board.name, self.board.find_owner(j))
            self.assertEqual(states.CLAIMED, j.state)

            time.sleep(0.6)
            self.assertEqual(states.UNCLAIMED, j.state)
            possible_jobs = list(self.board.iterjobs(only_unclaimed=True))
            self.assertEqual(1, len(possible_jobs))
开发者ID:jimbobhickville,项目名称:taskflow,代码行数:22,代码来源:test_redis_job.py

示例14: test_posting_claim

    def test_posting_claim(self):

        with connect_close(self.board):
            with self.flush(self.client):
                self.board.post('test', p_utils.temporary_log_book())

            self.assertEqual(1, self.board.job_count)
            possible_jobs = list(self.board.iterjobs(only_unclaimed=True))
            self.assertEqual(1, len(possible_jobs))
            j = possible_jobs[0]
            self.assertEqual(states.UNCLAIMED, j.state)

            with self.flush(self.client):
                self.board.claim(j, self.board.name)

            self.assertEqual(self.board.name, self.board.find_owner(j))
            self.assertEqual(states.CLAIMED, j.state)

            possible_jobs = list(self.board.iterjobs(only_unclaimed=True))
            self.assertEqual(0, len(possible_jobs))

        self.close_client(self.client)
        self.assertRaisesAttrAccess(excp.JobFailure, j, 'state')
开发者ID:HoratiusTang,项目名称:taskflow,代码行数:23,代码来源:base.py

示例15: test_posting_no_consume_wait

 def test_posting_no_consume_wait(self):
     with connect_close(self.board):
         jb = self.board.post('test', p_utils.temporary_log_book())
         self.assertFalse(jb.wait(0.1))
开发者ID:HoratiusTang,项目名称:taskflow,代码行数:4,代码来源:base.py


注:本文中的taskflow.utils.persistence_utils.temporary_log_book函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。