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


Python ModelMeta.session_start方法代码示例

本文整理汇总了Python中solar.dblayer.model.ModelMeta.session_start方法的典型用法代码示例。如果您正苦于以下问题:Python ModelMeta.session_start方法的具体用法?Python ModelMeta.session_start怎么用?Python ModelMeta.session_start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在solar.dblayer.model.ModelMeta的用法示例。


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

示例1: wait_finish

# 需要导入模块: from solar.dblayer.model import ModelMeta [as 别名]
# 或者: from solar.dblayer.model.ModelMeta import session_start [as 别名]
def wait_finish(uid, timeout):
    """Check if graph is finished

    Will return when no PENDING or INPROGRESS otherwise yields summary
    """
    start_time = time.time()

    while start_time + timeout >= time.time():
        dg = get_graph(uid)
        summary = Counter()
        summary.update({s.name: 0 for s in states})
        summary.update([task.status for task in dg.nodes()])
        yield summary
        if summary[states.PENDING.name] + summary[states.INPROGRESS.name] == 0:
            return
        else:
            # on db backends with snapshot isolation level and higher
            # updates wont be visible after start of transaction,
            # in order to report state correctly we will "refresh" transaction
            ModelMeta.session_end()
            ModelMeta.session_start()

    else:
        raise errors.ExecutionTimeout(
            'Run %s wasnt able to finish' % uid)
开发者ID:openstack,项目名称:solar,代码行数:27,代码来源:graph.py

示例2: _end_start_session

# 需要导入模块: from solar.dblayer.model import ModelMeta [as 别名]
# 或者: from solar.dblayer.model.ModelMeta import session_start [as 别名]
 def _end_start_session(cls, uid, identity):
     """Because of isolated versions of data in concurrent sessions
     we need to ensure that session will be re-started at certain
     hooks during locking logic
     """
     ModelMeta.session_end()
     ModelMeta.session_start()
开发者ID:loles,项目名称:solar-1,代码行数:9,代码来源:locking.py

示例3: create_all

# 需要导入模块: from solar.dblayer.model import ModelMeta [as 别名]
# 或者: from solar.dblayer.model.ModelMeta import session_start [as 别名]
def create_all():

    import sys
    if sys.executable.startswith(('python', )):
        # auto add session to only standalone python runs
        return

    from solar.dblayer.model import ModelMeta

    import atexit

    ModelMeta.session_start()

    atexit.register(ModelMeta.session_end)
开发者ID:aglarendil,项目名称:solar,代码行数:16,代码来源:standalone_session_wrapper.py

示例4: create_all

# 需要导入模块: from solar.dblayer.model import ModelMeta [as 别名]
# 或者: from solar.dblayer.model.ModelMeta import session_start [as 别名]
def create_all():

    import sys
    if sys.executable.split('/')[-1] not in ['python', 'python2']:
        # auto add session to only standalone python runs
        return

    from solar.dblayer.model import ModelMeta

    import atexit

    ModelMeta.session_start()

    atexit.register(ModelMeta.session_end)
开发者ID:loles,项目名称:solar-1,代码行数:16,代码来源:standalone_session_wrapper.py

示例5: test_revert_removal

# 需要导入模块: from solar.dblayer.model import ModelMeta [as 别名]
# 或者: from solar.dblayer.model.ModelMeta import session_start [as 别名]
def test_revert_removal():
    res = DBResource.from_dict(
        "test1",
        {
            "name": "test1",
            "base_path": "x",
            "state": RESOURCE_STATE.created.name,
            "meta_inputs": {"a": {"value": None, "schema": "str"}},
        },
    )
    res.inputs["a"] = "9"
    res.save_lazy()

    commited = CommitedResource.from_dict("test1", {"inputs": {"a": "9"}, "state": "operational"})
    commited.save_lazy()

    resource_obj = resource.load(res.name)
    resource_obj.remove()
    ModelMeta.save_all_lazy()

    changes = change.stage_changes()
    assert len(changes) == 1
    assert changes[0].diff == [["remove", "", [["a", "9"]]]]
    operations.move_to_commited(changes[0].log_action)

    ModelMeta.session_start()
    assert DBResource._c.obj_cache == {}
    assert DBResource.bucket.get("test1").siblings == []

    with mock.patch.object(resource, "read_meta") as mread:
        mread.return_value = {"input": {"a": {"schema": "str!"}}, "id": "mocked"}
        change.revert(changes[0].uid)
    ModelMeta.save_all_lazy()
    assert len(DBResource.bucket.get("test1").siblings) == 1

    resource_obj = resource.load("test1")
    assert resource_obj.args == {"a": "9", "location_id": "", "transports_id": ""}
开发者ID:aglarendil,项目名称:solar,代码行数:39,代码来源:test_system_log_api.py

示例6: pytest_runtest_call

# 需要导入模块: from solar.dblayer.model import ModelMeta [as 别名]
# 或者: from solar.dblayer.model.ModelMeta import session_start [as 别名]
def pytest_runtest_call(item):
    ModelMeta.session_start()
开发者ID:pigmej,项目名称:solar,代码行数:4,代码来源:conftest.py

示例7: pytest_runtest_setup

# 需要导入模块: from solar.dblayer.model import ModelMeta [as 别名]
# 或者: from solar.dblayer.model.ModelMeta import session_start [as 别名]
def pytest_runtest_setup(item):
    ModelMeta.session_start()
开发者ID:loles,项目名称:solar,代码行数:4,代码来源:conftest.py

示例8: session_start

# 需要导入模块: from solar.dblayer.model import ModelMeta [as 别名]
# 或者: from solar.dblayer.model.ModelMeta import session_start [as 别名]
 def session_start(ctxt):
     log.debug('Session start ID %s', id(gevent.getcurrent()))
     ModelMeta.session_start()
开发者ID:pigmej,项目名称:solar,代码行数:5,代码来源:conftest.py


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