• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python persistence_utils.temporary_log_book函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: execute

    def execute(self):
        print('executing %s' % self)
        return 'ok'


def flow_factory():
    return lf.Flow('resume from backend example').add(
        TestTask(name='first'),
        InterruptTask(name='boom'),
        TestTask(name='second'))


### INITIALIZE PERSISTENCE ####################################

backend = get_backend()
logbook = p_utils.temporary_log_book(backend)


### CREATE AND RUN THE FLOW: FIRST ATTEMPT ####################

flow = flow_factory()
flowdetail = p_utils.create_flow_detail(flow, logbook, backend)
engine = taskflow.engines.load(flow, flow_detail=flowdetail,
                               backend=backend)

print_task_states(flowdetail, "At the beginning, there is no state")
print_wrapped("Running")
engine.run()
print_task_states(flowdetail, "After running")

开发者ID:SEJeff,项目名称:taskflow,代码行数:29,代码来源:resume_from_backend.py


示例17: occur

from taskflow.engines.action_engine import engine
from taskflow.patterns import linear_flow as lf
from taskflow.persistence.backends import impl_memory
from taskflow import task
from taskflow.utils import persistence_utils

# INTRO: This examples shows how to run a engine using the engine iteration
# capability, in between iterations other activities occur (in this case a
# value is output to stdout); but more complicated actions can occur at the
# boundary when a engine yields its current state back to the caller.


class EchoNameTask(task.Task):
    def execute(self):
        print(self.name)


f = lf.Flow("counter")
for i in range(0, 10):
    f.add(EchoNameTask("echo_%s" % (i + 1)))

be = impl_memory.MemoryBackend()
book = persistence_utils.temporary_log_book(be)
fd = persistence_utils.create_flow_detail(f, book, be)
e = engine.SingleThreadedActionEngine(f, fd, be, {})
e.compile()
e.prepare()

for i, st in enumerate(e.run_iter(), 1):
    print("Transition %s: %s" % (i, st))
开发者ID:celttechie,项目名称:taskflow,代码行数:30,代码来源:run_by_iter_enumerate.py


示例18: poster

 def poster(wait_post=0.2):
     ev.wait()  # wait until the waiter is active
     time.sleep(wait_post)
     self.board.post('test', p_utils.temporary_log_book())
开发者ID:zhxqgithub,项目名称:taskflow,代码行数:4,代码来源:base.py


示例19: setUp

 def setUp(self):
     super(EngineTestBase, self).setUp()
     self.values = []
     self.backend = impl_memory.MemoryBackend(conf={})
     self.book = p_utils.temporary_log_book(self.backend)
开发者ID:jessicalucci,项目名称:TaskManagement,代码行数:5,代码来源:test_action_engine.py


示例20: poster

 def poster(wait_post=0.2):
     if not ev.wait(test_utils.WAIT_TIMEOUT):
         raise RuntimeError("Waiter did not appear ready"
                            " in %s seconds" % test_utils.WAIT_TIMEOUT)
     time.sleep(wait_post)
     self.board.post('test', p_utils.temporary_log_book())
开发者ID:HoratiusTang,项目名称:taskflow,代码行数:6,代码来源:base.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python reflection.get_callable_args函数代码示例发布时间:2022-05-27
下一篇:
Python persistence_utils.temporary_flow_detail函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap