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


Python SyncbackService._restart_workers方法代码示例

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


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

示例1: test_folder_name_translation

# 需要导入模块: from inbox.transactions.actions import SyncbackService [as 别名]
# 或者: from inbox.transactions.actions.SyncbackService import _restart_workers [as 别名]
def test_folder_name_translation(empty_db, generic_account, imap_api_client,
                                 mock_imapclient, monkeypatch):
    from inbox.transactions.actions import SyncbackService
    syncback = SyncbackService(syncback_id=0, process_number=0,
                               total_processes=1, num_workers=2)

    imap_namespaces = (((u'INBOX.', u'.'),),)
    mock_imapclient.create_folder = mock.Mock()
    mock_imapclient.namespace = mock.Mock(return_value=imap_namespaces)

    folder_list = [(('\\HasChildren',), '.', u'INBOX')]
    mock_imapclient.list_folders = mock.Mock(return_value=folder_list)
    mock_imapclient.has_capability = mock.Mock(return_value=True)

    folder_prefix, folder_separator = imap_namespaces[0][0]
    generic_account.folder_prefix = folder_prefix
    generic_account.folder_separator = folder_separator
    empty_db.session.commit()

    folder_json = {'display_name': 'Taxes/Accounting'}
    imap_api_client.post_data('/folders', folder_json)

    syncback._process_log()
    syncback._restart_workers()
    while not syncback.task_queue.empty():
        gevent.sleep(0.1)
    mock_imapclient.create_folder.assert_called_with('INBOX.Taxes.Accounting')
开发者ID:aabde,项目名称:sync-engine,代码行数:29,代码来源:test_folders.py

示例2: test_actions_are_claimed

# 需要导入模块: from inbox.transactions.actions import SyncbackService [as 别名]
# 或者: from inbox.transactions.actions.SyncbackService import _restart_workers [as 别名]
def test_actions_are_claimed(purge_accounts_and_actions, patched_task):
    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(
        syncback_id=0, process_number=1, total_processes=2, num_workers=2)
    service._restart_workers()
    service._process_log()

    while not service.task_queue.empty():
        gevent.sleep(0)

    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:aabde,项目名称:sync-engine,代码行数:30,代码来源:test_syncback_logic.py

示例3: test_failed_event_creation

# 需要导入模块: from inbox.transactions.actions import SyncbackService [as 别名]
# 或者: from inbox.transactions.actions.SyncbackService import _restart_workers [as 别名]
def test_failed_event_creation(db, patched_syncback_task, default_account, event):
    schedule_action('create_event', event, default_account.namespace.id, db.session)
    schedule_action('update_event', event, default_account.namespace.id, db.session)
    schedule_action('update_event', event, default_account.namespace.id, db.session)
    schedule_action('delete_event', event, default_account.namespace.id, db.session)
    db.session.commit()

    NUM_WORKERS = 2
    service = SyncbackService(syncback_id=0, process_number=0,
        total_processes=NUM_WORKERS, num_workers=NUM_WORKERS)
    service._restart_workers()
    service._process_log()

    while not service.task_queue.empty():
        gevent.sleep(0.1)

    # This has to be a separate while-loop because there's a brief moment where
    # the task queue is empty, but num_idle_workers hasn't been updated yet.
    # On slower systems, we might need to sleep a bit between the while-loops.
    while service.num_idle_workers != NUM_WORKERS:
        gevent.sleep(0.1)

    q = db.session.query(ActionLog).filter_by(record_id=event.id).all()
    assert all(a.status == 'failed' for a in q)
开发者ID:nylas,项目名称:sync-engine,代码行数:26,代码来源:test_actions.py


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