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


Python Session.expire_all方法代码示例

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


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

示例1: _cancel_jobs

# 需要导入模块: from fts3rest.lib.base import Session [as 别名]
# 或者: from fts3rest.lib.base.Session import expire_all [as 别名]
def _cancel_jobs(dn):
    """
    Cancel all jobs that belong to dn.
    Returns the list of affected jobs ids.
    """
    jobs = Session.query(Job.job_id).filter(Job.job_state.in_(JobActiveStates)).filter(Job.user_dn == dn)
    job_ids = map(lambda j: j[0], jobs)

    try:
        now = datetime.utcnow()
        for job_id in job_ids:
            Session.query(File).filter(File.job_id == job_id).filter(File.file_state.in_(FileActiveStates))\
                .update({
                    'file_state': 'CANCELED', 'reason': 'User banned',
                    'job_finished': now, 'finish_time': now
                }, synchronize_session=False)
            Session.query(Job).filter(Job.job_id == job_id)\
                .update({
                    'job_state': 'CANCELED', 'reason': 'User banned',
                    'job_finished': now, 'finish_time': now
                }, synchronize_session=False)
        Session.commit()
	Session.expire_all()
        return job_ids
    except Exception:
        Session.rollback()
        raise
开发者ID:andrea-manzi,项目名称:fts3-rest,代码行数:29,代码来源:banning.py

示例2: _set_to_wait

# 需要导入模块: from fts3rest.lib.base import Session [as 别名]
# 或者: from fts3rest.lib.base.Session import expire_all [as 别名]
def _set_to_wait(storage=None, vo_name=None, timeout=0):
    """
    Updates the transfers that have the given storage either in source or destination,
    and belong to the given VO.
    Returns the list of affected jobs ids.
    """
    job_ids = Session.query(distinct(File.job_id))\
        .filter((File.source_se == storage) | (File.dest_se == storage)).filter(File.file_state.in_(FileActiveStates))
    if vo_name:
        job_ids = job_ids.filter(File.vo_name == vo_name)
    job_ids = map(lambda j: j[0], job_ids.all())

    try:
        for job_id in job_ids:
            Session.query(File).filter(File.job_id == job_id).filter(File.file_state.in_(FileActiveStates))\
                .update({'wait_timestamp': datetime.utcnow(), 'wait_timeout': timeout}, synchronize_session=False)

        Session.commit()
	Session.expire_all()
        return job_ids
    except Exception:
        Session.rollback()
        raise
开发者ID:andrea-manzi,项目名称:fts3-rest,代码行数:25,代码来源:banning.py


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