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

Python persistence_utils.temporary_flow_detail函数代码示例

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

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



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

示例1: test_posting_with_book

    def test_posting_with_book(self):
        backend = impl_dir.DirBackend(conf={
            'path': self.makeTmpDir(),
        })
        backend.get_connection().upgrade()
        book, flow_detail = p_utils.temporary_flow_detail(backend)
        self.assertEqual(1, len(book))

        client, board = self.create_board(persistence=backend)
        with connect_close(board):
            with self.flush(client):
                board.post('test', book)

            possible_jobs = list(board.iterjobs(only_unclaimed=True))
            self.assertEqual(1, len(possible_jobs))
            j = possible_jobs[0]
            self.assertEqual(1, len(j.book))
            self.assertEqual(book.name, j.book.name)
            self.assertEqual(book.uuid, j.book.uuid)
            self.assertEqual(book.name, j.book_name)
            self.assertEqual(book.uuid, j.book_uuid)

            flow_details = list(j.book)
            self.assertEqual(flow_detail.uuid, flow_details[0].uuid)
            self.assertEqual(flow_detail.name, flow_details[0].name)
开发者ID:HoratiusTang,项目名称:taskflow,代码行数:25,代码来源:base.py


示例2: test_no_meta

 def test_no_meta(self):
     _lb, flow_detail = p_utils.temporary_flow_detail()
     self.assertEqual({}, flow_detail.meta)
     self.assertRaisesRegexp(ValueError,
                             '^Cannot .* no factory information saved.$',
                             taskflow.engines.flow_from_detail,
                             flow_detail)
开发者ID:celttechie,项目名称:taskflow,代码行数:7,代码来源:test_engine_helpers.py


示例3: test_fail_run

    def test_fail_run(self):
        components = self.make_components()
        components.conductor.connect()
        consumed_event = threading_utils.Event()

        def on_consume(state, details):
            consumed_event.set()

        components.board.notifier.register(jobboard.REMOVAL, on_consume)
        with close_many(components.conductor, components.client):
            t = threading_utils.daemon_thread(components.conductor.run)
            t.start()
            lb, fd = pu.temporary_flow_detail(components.persistence)
            engines.save_factory_details(fd, test_factory,
                                         [True], {},
                                         backend=components.persistence)
            components.board.post('poke', lb,
                                  details={'flow_uuid': fd.uuid})
            self.assertTrue(consumed_event.wait(test_utils.WAIT_TIMEOUT))
            self.assertTrue(components.conductor.stop(test_utils.WAIT_TIMEOUT))
            self.assertFalse(components.conductor.dispatching)

        persistence = components.persistence
        with contextlib.closing(persistence.get_connection()) as conn:
            lb = conn.get_logbook(lb.uuid)
            fd = lb.find(fd.uuid)
        self.assertIsNotNone(fd)
        self.assertEqual(st.REVERTED, fd.state)
开发者ID:TheSriram,项目名称:taskflow,代码行数:28,代码来源:test_conductor.py


示例4: test_sequential_flow_iter_suspend_resume

    def test_sequential_flow_iter_suspend_resume(self):
        flow = lf.Flow('flow-2').add(
            utils.ProgressingTask(name='task1'),
            utils.ProgressingTask(name='task2')
        )
        lb, fd = p_utils.temporary_flow_detail(self.backend)

        engine = self._make_engine(flow, flow_detail=fd)
        with utils.CaptureListener(engine, capture_flow=False) as capturer:
            it = engine.run_iter()
            gathered_states = []
            suspend_it = None
            while True:
                try:
                    s = it.send(suspend_it)
                    gathered_states.append(s)
                    if s == states.WAITING:
                        # Stop it before task2 runs/starts.
                        suspend_it = True
                except StopIteration:
                    break
        self.assertTrue(len(gathered_states) > 0)
        expected = ['task1.t RUNNING', 'task1.t SUCCESS(5)']
        self.assertEqual(expected, capturer.values)
        self.assertEqual(states.SUSPENDED, engine.storage.get_flow_state())

        # Attempt to resume it and see what runs now...
        with utils.CaptureListener(engine, capture_flow=False) as capturer:
            gathered_states = list(engine.run_iter())
        self.assertTrue(len(gathered_states) > 0)
        expected = ['task2.t RUNNING', 'task2.t SUCCESS(5)']
        self.assertEqual(expected, capturer.values)
        self.assertEqual(states.SUCCESS, engine.storage.get_flow_state())
开发者ID:Dynavisor,项目名称:taskflow,代码行数:33,代码来源:test_engines.py


示例5: _get_storage

 def _get_storage(self, flow_detail=None, threaded=False):
     if flow_detail is None:
         _lb, flow_detail = p_utils.temporary_flow_detail(self.backend)
     storage_cls = storage.SingleThreadedStorage
     if threaded:
         storage_cls = storage.MultiThreadedStorage
     return storage_cls(flow_detail=flow_detail, backend=self.backend)
开发者ID:varunarya10,项目名称:taskflow,代码行数:7,代码来源:test_storage.py


示例6: test_run_max_dispatches

    def test_run_max_dispatches(self):
        components = self.make_components()
        components.conductor.connect()
        consumed_event = threading.Event()

        def on_consume(state, details):
            consumed_event.set()

        components.board.notifier.register(base.REMOVAL, on_consume)
        with close_many(components.client, components.conductor):
            t = threading_utils.daemon_thread(
                lambda: components.conductor.run(max_dispatches=5))
            t.start()
            lb, fd = pu.temporary_flow_detail(components.persistence)
            engines.save_factory_details(fd, test_factory,
                                         [False], {},
                                         backend=components.persistence)
            for _ in range(5):
                components.board.post('poke', lb,
                                      details={'flow_uuid': fd.uuid})
                self.assertTrue(consumed_event.wait(
                    test_utils.WAIT_TIMEOUT))
            components.board.post('poke', lb,
                                  details={'flow_uuid': fd.uuid})
            components.conductor.stop()
            self.assertTrue(components.conductor.wait(test_utils.WAIT_TIMEOUT))
            self.assertFalse(components.conductor.dispatching)
开发者ID:jimbobhickville,项目名称:taskflow,代码行数:27,代码来源:test_conductors.py


示例7: test_get_without_save

    def test_get_without_save(self):
        _lb, flow_detail = p_utils.temporary_flow_detail(self.backend)
        td = logbook.TaskDetail(name='my_task', uuid='42')
        flow_detail.add(td)

        s = storage.Storage(backend=self.backend, flow_detail=flow_detail)
        self.assertEquals('42', s.get_task_uuid('my_task'))
开发者ID:rl-0x0,项目名称:taskflow,代码行数:7,代码来源:test_storage.py


示例8: test_combined_store

    def test_combined_store(self):
        components = self.make_components()
        components.conductor.connect()
        consumed_event = threading.Event()

        def on_consume(state, details):
            consumed_event.set()

        flow_store = {'x': True, 'y': False}
        job_store = {'z': None}

        components.board.notifier.register(base.REMOVAL, on_consume)
        with close_many(components.conductor, components.client):
            t = threading_utils.daemon_thread(components.conductor.run)
            t.start()
            lb, fd = pu.temporary_flow_detail(components.persistence,
                                              meta={'store': flow_store})
            engines.save_factory_details(fd, test_store_factory,
                                         [], {},
                                         backend=components.persistence)
            components.board.post('poke', lb,
                                  details={'flow_uuid': fd.uuid,
                                           'store': job_store})
            self.assertTrue(consumed_event.wait(test_utils.WAIT_TIMEOUT))
            components.conductor.stop()
            self.assertTrue(components.conductor.wait(test_utils.WAIT_TIMEOUT))
            self.assertFalse(components.conductor.dispatching)

        persistence = components.persistence
        with contextlib.closing(persistence.get_connection()) as conn:
            lb = conn.get_logbook(lb.uuid)
            fd = lb.find(fd.uuid)
        self.assertIsNotNone(fd)
        self.assertEqual(st.SUCCESS, fd.state)
开发者ID:jimbobhickville,项目名称:taskflow,代码行数:34,代码来源:test_conductors.py


示例9: test_ensure_existing_task

 def test_ensure_existing_task(self):
     _lb, flow_detail = p_utils.temporary_flow_detail(self.backend)
     td = logbook.TaskDetail(name="my_task", uuid="42")
     flow_detail.add(td)
     s = self._get_storage(flow_detail)
     s.ensure_atom(test_utils.NoopTask("my_task"))
     self.assertEqual("42", s.get_atom_uuid("my_task"))
开发者ID:balagopalraj,项目名称:clearlinux,代码行数:7,代码来源:test_storage.py


示例10: test_ensure_existing_task

 def test_ensure_existing_task(self):
     _lb, flow_detail = p_utils.temporary_flow_detail(self.backend)
     td = models.TaskDetail(name='my_task', uuid='42')
     flow_detail.add(td)
     s = self._get_storage(flow_detail)
     s.ensure_atom(test_utils.NoopTask('my_task'))
     self.assertEqual('42', s.get_atom_uuid('my_task'))
开发者ID:junneyang,项目名称:taskflow,代码行数:7,代码来源:test_storage.py


示例11: test_get_flow_state

 def test_get_flow_state(self):
     _lb, fd = p_utils.temporary_flow_detail(backend=self.backend)
     fd.state = states.FAILURE
     with contextlib.closing(self.backend.get_connection()) as conn:
         fd.update(conn.update_flow_details(fd))
     s = storage.Storage(flow_detail=fd, backend=self.backend)
     self.assertEquals(s.get_flow_state(), states.FAILURE)
开发者ID:SEJeff,项目名称:taskflow,代码行数:7,代码来源:test_storage.py


示例12: test_sequential_flow_iter_suspend_resume

    def test_sequential_flow_iter_suspend_resume(self):
        flow = lf.Flow('flow-2').add(
            utils.SaveOrderTask(name='task1'),
            utils.SaveOrderTask(name='task2')
        )
        _lb, fd = p_utils.temporary_flow_detail(self.backend)
        e = self._make_engine(flow, flow_detail=fd)
        it = e.run_iter()
        gathered_states = []
        suspend_it = None
        while True:
            try:
                s = it.send(suspend_it)
                gathered_states.append(s)
                if s == states.WAITING:
                    # Stop it before task2 runs/starts.
                    suspend_it = True
            except StopIteration:
                break
        self.assertTrue(len(gathered_states) > 0)
        self.assertEqual(self.values, ['task1'])
        self.assertEqual(states.SUSPENDED, e.storage.get_flow_state())

        # Attempt to resume it and see what runs now...
        #
        # NOTE(harlowja): Clear all the values, but don't reset the reference.
        while len(self.values):
            self.values.pop()
        gathered_states = list(e.run_iter())
        self.assertTrue(len(gathered_states) > 0)
        self.assertEqual(self.values, ['task2'])
        self.assertEqual(states.SUCCESS, e.storage.get_flow_state())
开发者ID:zhxqgithub,项目名称:taskflow,代码行数:32,代码来源:test_action_engine.py


示例13: _get_storage

 def _get_storage(self, threaded=False):
     _lb, flow_detail = p_utils.temporary_flow_detail(self.backend)
     if threaded:
         return storage.MultiThreadedStorage(backend=self.backend,
                                             flow_detail=flow_detail)
     else:
         return storage.SingleThreadedStorage(backend=self.backend,
                                              flow_detail=flow_detail)
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:8,代码来源:test_storage.py


示例14: test_ensure_existing_task

    def test_ensure_existing_task(self):
        _lb, flow_detail = p_utils.temporary_flow_detail(self.backend)
        td = logbook.TaskDetail(name='my_task', uuid='42')
        flow_detail.add(td)

        s = storage.Storage(backend=self.backend, flow_detail=flow_detail)
        s.ensure_task('my_task')
        self.assertEqual('42', s.get_task_uuid('my_task'))
开发者ID:toabctl,项目名称:taskflow,代码行数:8,代码来源:test_storage.py


示例15: test_no_importable_function

 def test_no_importable_function(self):
     _lb, flow_detail = p_utils.temporary_flow_detail()
     flow_detail.meta = dict(factory=dict(
         name='you can not import me, i contain spaces'
     ))
     expected_msg = '^Could not import factory'
     with self.assertRaisesRegexp(ImportError, expected_msg):
         taskflow.engines.flow_from_detail(flow_detail)
开发者ID:achanda,项目名称:taskflow,代码行数:8,代码来源:test_engine_helpers.py


示例16: test_ensure_task_fd

 def test_ensure_task_fd(self):
     _lb, flow_detail = p_utils.temporary_flow_detail(self.backend)
     s = storage.Storage(backend=self.backend, flow_detail=flow_detail)
     s.ensure_task('my task', '3.11')
     td = flow_detail.find(s.get_task_uuid('my task'))
     self.assertIsNotNone(td)
     self.assertEqual(td.name, 'my task')
     self.assertEqual(td.version, '3.11')
     self.assertEqual(td.state, states.PENDING)
开发者ID:rl-0x0,项目名称:taskflow,代码行数:9,代码来源:test_storage.py


示例17: test_ensure_task_flow_detail

 def test_ensure_task_flow_detail(self):
     _lb, flow_detail = p_utils.temporary_flow_detail(self.backend)
     s = self._get_storage(flow_detail)
     s.ensure_task("my task", "3.11")
     td = flow_detail.find(s.get_task_uuid("my task"))
     self.assertIsNotNone(td)
     self.assertEqual(td.name, "my task")
     self.assertEqual(td.version, "3.11")
     self.assertEqual(td.state, states.PENDING)
开发者ID:varunarya10,项目名称:taskflow,代码行数:9,代码来源:test_storage.py


示例18: test_transient_storage_restore

    def test_transient_storage_restore(self):
        _lb, flow_detail = p_utils.temporary_flow_detail(self.backend)
        s = self._get_storage(flow_detail=flow_detail)
        s.inject([("a", "b")], transient=True)
        s.inject([("b", "c")])

        s2 = self._get_storage(flow_detail=flow_detail)
        results = s2.fetch_all()
        self.assertEqual({"b": "c"}, results)
开发者ID:balagopalraj,项目名称:clearlinux,代码行数:9,代码来源:test_storage.py


示例19: test_no_arg_factory

    def test_no_arg_factory(self):
        name = 'some.test.factory'
        _lb, flow_detail = p_utils.temporary_flow_detail()
        flow_detail.meta = dict(factory=dict(name=name))

        with mock.patch('oslo_utils.importutils.import_class',
                        return_value=lambda: 'RESULT') as mock_import:
            result = taskflow.engines.flow_from_detail(flow_detail)
            mock_import.assert_called_once_with(name)
        self.assertEqual('RESULT', result)
开发者ID:FedericoCeratto,项目名称:taskflow,代码行数:10,代码来源:test_engine_helpers.py


示例20: test_deregister

 def test_deregister(self):
     """Verify that register and deregister don't blow up"""
     with contextlib.closing(impl_memory.MemoryBackend()) as be:
         flow = lf.Flow("test")
         flow.add(SleepyTask("test-1", sleep_for=0.1))
         (lb, fd) = persistence_utils.temporary_flow_detail(be)
         e = self._make_engine(flow, fd, be)
         l = timing.DurationListener(e)
         l.register()
         l.deregister()
开发者ID:junneyang,项目名称:taskflow,代码行数:10,代码来源:test_listeners.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python persistence_utils.temporary_log_book函数代码示例发布时间:2022-05-27
下一篇:
Python misc.parse_uri函数代码示例发布时间: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