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


Python SyncbackService.workers方法代码示例

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


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

示例1: test_actions_are_claimed

# 需要导入模块: from inbox.transactions.actions import SyncbackService [as 别名]
# 或者: from inbox.transactions.actions.SyncbackService import workers [as 别名]
def test_actions_are_claimed(purge_accounts_and_actions, patched_worker):
    with session_scope_by_shard_id(0) as db_session:
        account = add_generic_imap_account(db_session,
                                    email_address='{}@test.com'.format(0))
        schedule_test_action(db_session, account)

    with session_scope_by_shard_id(1) as db_session:
        account = add_generic_imap_account(db_session,
                                    email_address='{}@test.com'.format(1))
        schedule_test_action(db_session, account)

    service = SyncbackService(cpu_id=1, total_cpus=2)
    service.workers = set()
    service._process_log()

    gevent.joinall(list(service.workers))

    with session_scope_by_shard_id(0) as db_session:
        q = db_session.query(ActionLog)
        assert q.count() == 1
        assert all(a.status == 'pending' for a in q)

    with session_scope_by_shard_id(1) as db_session:
        q = db_session.query(ActionLog)
        assert q.count() == 1
        assert all(a.status != 'pending' for a in q)
开发者ID:GordonYip,项目名称:sync-engine,代码行数:28,代码来源:test_syncback_logic.py

示例2: test_actions_claimed_by_a_single_service

# 需要导入模块: from inbox.transactions.actions import SyncbackService [as 别名]
# 或者: from inbox.transactions.actions.SyncbackService import workers [as 别名]
def test_actions_claimed_by_a_single_service(purge_accounts_and_actions,
                                             patched_worker):
    actionlogs = []
    for key in (0, 1):
        with session_scope_by_shard_id(key) as db_session:
            account = make_imap_account(db_session, '{}@test.com'.format(key))
            schedule_test_action(db_session, account)
            actionlogs += [db_session.query(ActionLog).one().id]

    services = []
    for cpu_id in (0, 1):
        service = SyncbackService(cpu_id=cpu_id, total_cpus=2)
        service.workers = set()
        service._process_log()
        services.append(service)

    for i, service in enumerate(services):
        assert len(service.workers) == 1
        assert list(service.workers)[0].action_log_id == actionlogs[i]
        gevent.joinall(list(service.workers))
开发者ID:uvatbc,项目名称:sync-engine,代码行数:22,代码来源:test_syncback_logic.py


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