本文整理汇总了Python中pulp.server..tasks._delete_worker函数的典型用法代码示例。如果您正苦于以下问题:Python _delete_worker函数的具体用法?Python _delete_worker怎么用?Python _delete_worker使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_delete_worker函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_no_entry_for_worker_does_not_raise_exception
def test_no_entry_for_worker_does_not_raise_exception(self):
self.mock_resources.filter_workers.return_value = []
try:
tasks._delete_worker('worker1')
except Exception:
self.fail('_delete_worker() on a Worker that is not in the database caused an '
'Exception')
开发者ID:AndreaGiardini,项目名称:pulp,代码行数:7,代码来源:test_tasks.py
示例2: test_no_entry_for_worker_does_not_raise_exception
def test_no_entry_for_worker_does_not_raise_exception(self, mock_worker_objects):
mock_worker_objects.get.return_value = []
try:
tasks._delete_worker('worker1')
except Exception:
self.fail('_delete_worker() on a Worker that is not in the database caused an '
'Exception')
开发者ID:hgschmie,项目名称:pulp,代码行数:7,代码来源:test_tasks.py
示例3: initialize_worker
def initialize_worker(sender, instance, **kwargs):
"""
This function performs all the necessary initialization of the Celery worker.
It starts by cleaning up old state if this worker was previously running, but died unexpectedly.
In such cases, any Pulp tasks that were running or waiting on this worker will show incorrect
state. Any reserved_resource reservations associated with the previous worker will also be
removed along with the worker entry in the database itself. The working directory specified in
/etc/pulp/server.conf (/var/cache/pulp/<worker_name>) by default is removed and recreated. This
is called early in the worker start process, and later when it's fully online, pulp_celerybeat
will discover the worker as usual to allow new work to arrive at this worker. If there is no
previous work to cleanup, this method still runs, but has no effect on the database.
After cleaning up old state, it ensures the existence of the worker's working directory.
Lastly, this function makes the call to Pulp's initialization code.
It uses the celeryd_after_setup signal[0] so that it gets called by Celery after logging is
initialized, but before Celery starts to run tasks.
[0] http://celery.readthedocs.org/en/latest/userguide/signals.html#celeryd-after-setup
:param sender: The hostname of the worker
:type sender: basestring
:param instance: The Worker instance to be initialized (unused)
:type instance: celery.apps.worker.Worker
:param kwargs: Other params (unused)
:type kwargs: dict
"""
initialization.initialize()
tasks._delete_worker(sender, normal_shutdown=True)
# Create a new working directory for worker that is starting now
common_utils.create_worker_working_directory(sender)
开发者ID:credativ,项目名称:pulp,代码行数:35,代码来源:app.py
示例4: test_cancels_all_found_task_status_objects
def test_cancels_all_found_task_status_objects(self):
mock_task_id_a = mock.Mock()
mock_task_id_b = mock.Mock()
self.mock_task_status.objects.return_value = [{'task_id': mock_task_id_a},
{'task_id': mock_task_id_b}]
tasks._delete_worker('worker1')
self.mock_cancel.assert_has_calls([mock.call(mock_task_id_a), mock.call(mock_task_id_b)])
开发者ID:hgschmie,项目名称:pulp,代码行数:8,代码来源:test_tasks.py
示例5: test__delete_worker_normal_shutdown_true
def test__delete_worker_normal_shutdown_true(self, mock_logger, mock_underscore):
"""
Call _delete_worker() with the normal_shutdown keyword argument set to True. This should
not make any calls to _() or logger().
"""
tasks._delete_worker('does not exist Worker name')
self.assertTrue(not mock_underscore.called)
self.assertTrue(not mock_logger.called)
开发者ID:unixbhaskar,项目名称:pulp,代码行数:8,代码来源:test_tasks.py
示例6: test_removes_the_worker
def test_removes_the_worker(self, mock_worker_objects):
mock_document = mock.Mock()
mock_get = mock.Mock()
mock_get.get.return_value = [mock_document]
mock_worker_objects.return_value = mock_get
tasks._delete_worker('worker1')
mock_document.delete.assert_called_once()
开发者ID:hgschmie,项目名称:pulp,代码行数:9,代码来源:test_tasks.py
示例7: test__delete_worker_no_database_entry
def test__delete_worker_no_database_entry(self):
"""
Call _delete_worker() with a Worker that is not in the database. _delete_worker() relies on
the database information, so it should return without error when called in this way.
"""
try:
tasks._delete_worker('does not exist Worker name')
except Exception:
self.fail('_delete_worker() on a Worker that is not in the database caused an '
'Exception')
开发者ID:unixbhaskar,项目名称:pulp,代码行数:10,代码来源:test_tasks.py
示例8: shutdown
def shutdown(self, consumer):
"""
Called when the consumer is shut down.
So far, this just cleans up the database by removing the worker's record in
the workers collection.
:param consumer: The consumer instance
:type consumer: celery.worker.consumer.Consumer
"""
tasks._delete_worker(consumer.hostname, normal_shutdown=True)
开发者ID:alexxa,项目名称:pulp,代码行数:11,代码来源:app.py
示例9: test_cancels_all_found_task_status_objects
def test_cancels_all_found_task_status_objects(self):
mock_task_id_a = mock.Mock()
mock_task_id_b = mock.Mock()
self.mock_task_status_manager.find_by_criteria.return_value = [{'task_id': mock_task_id_a},
{'task_id': mock_task_id_b}]
tasks._delete_worker('worker1')
find_by_criteria = self.mock_task_status_manager.find_by_criteria
find_by_criteria.assert_called_once_with(self.mock_criteria.return_value)
self.mock_cancel.assert_has_calls([mock.call(mock_task_id_a), mock.call(mock_task_id_b)])
开发者ID:omps,项目名称:pulp,代码行数:11,代码来源:test_tasks.py
示例10: shutdown_worker
def shutdown_worker(signal, sender, **kwargs):
"""
Called when a worker is shutdown.
So far, this just cleans up the database by removing the worker's record in
the workers collection.
:param signal: The signal being sent to the worker
:type signal: int
:param instance: The hostname of the worker
:type instance: celery.apps.worker.Worker
:param kwargs: Other params (unused)
:type kwargs: dict
"""
tasks._delete_worker(sender.hostname, normal_shutdown=True)
开发者ID:BrnoPCmaniak,项目名称:pulp,代码行数:13,代码来源:app.py
示例11: initialize_worker
def initialize_worker(sender, instance, **kwargs):
"""
This function performs all the necessary initialization of the Celery worker.
We clean up old state in case this worker was previously running, but died unexpectedly.
In such cases, any Pulp tasks that were running or waiting on this worker will show incorrect
state. Any reserved_resource reservations associated with the previous worker will also be
removed along with the worker entry in the database itself. The working directory specified in
/etc/pulp/server.conf (/var/cache/pulp/<worker_name>) by default is removed and recreated. This
is called early in the worker start process, and later when it's fully online, pulp_celerybeat
will discover the worker as usual to allow new work to arrive at this worker. If there is no
previous work to cleanup, this method still runs, but has no effect on the database.
After cleaning up old state, it ensures the existence of the worker's working directory.
Lastly, this function makes the call to Pulp's initialization code.
It uses the celeryd_after_setup signal[0] so that it gets called by Celery after logging is
initialized, but before Celery starts to run tasks.
If the worker is a resource manager, it tries to acquire a lock stored within the database.
If the lock cannot be acquired immediately, it will wait until the currently active instance
becomes unavailable, at which point the worker cleanup routine will clear the lock for us to
acquire. While the worker remains in this waiting state, it is not connected to the broker and
will not attempt to do any work. A side effect of this is that, if terminated while in this
state, the process will not send the "worker-offline" signal used by the EventMonitor to
immediately clean up terminated workers. Therefore, we override the SIGTERM signal handler
while in this state so that cleanup is done properly.
[0] http://celery.readthedocs.org/en/latest/userguide/signals.html#celeryd-after-setup
:param sender: The hostname of the worker
:type sender: basestring
:param instance: The Worker instance to be initialized (unused)
:type instance: celery.apps.worker.Worker
:param kwargs: Other params (unused)
:type kwargs: dict
"""
initialization.initialize()
# Delete any potential old state
tasks._delete_worker(sender, normal_shutdown=True)
# Create a new working directory for worker that is starting now
common_utils.delete_worker_working_directory(sender)
common_utils.create_worker_working_directory(sender)
# If the worker is a resource manager, try to acquire the lock, or wait until it
# can be acquired
if sender.startswith(constants.RESOURCE_MANAGER_WORKER_NAME):
get_resource_manager_lock(sender)
开发者ID:alexxa,项目名称:pulp,代码行数:51,代码来源:app.py
示例12: test_criteria_is_used_in_filter_workers
def test_criteria_is_used_in_filter_workers(self):
tasks._delete_worker('worker1')
self.mock_resources.filter_workers.assert_called_once_with(self.mock_criteria.return_value)
开发者ID:AndreaGiardini,项目名称:pulp,代码行数:3,代码来源:test_tasks.py
示例13: test_removes_all_associated_reserved_resource_entries
def test_removes_all_associated_reserved_resource_entries(self):
tasks._delete_worker('worker1')
self.assertTrue(self.mock_reserved_resource.get_collection.called)
remove = self.mock_reserved_resource.get_collection.return_value.remove
remove.assert_called_once_with({'worker_name': 'worker1'})
开发者ID:hgschmie,项目名称:pulp,代码行数:5,代码来源:test_tasks.py
示例14: test_removes_the_worker
def test_removes_the_worker(self):
mock_worker = mock.Mock()
self.mock_resources.filter_workers.return_value = tuple([mock_worker])
tasks._delete_worker('worker1')
mock_worker.delete.assert_called_once_with()
开发者ID:AndreaGiardini,项目名称:pulp,代码行数:5,代码来源:test_tasks.py
示例15: test_normal_shutdown_true_logs_correctly
def test_normal_shutdown_true_logs_correctly(self):
tasks._delete_worker('worker1', normal_shutdown=True)
self.assertTrue(not self.mock_gettext.called)
self.assertTrue(not self.mock_logger.error.called)
开发者ID:hgschmie,项目名称:pulp,代码行数:4,代码来源:test_tasks.py
示例16: test_normal_shutdown_not_specified_logs
def test_normal_shutdown_not_specified_logs(self):
self.mock_gettext.return_value = 'asdf %(name)s asdf'
tasks._delete_worker('worker1')
self.mock_gettext.assert_called_once_with(
'The worker named %(name)s is missing. Canceling the tasks in its queue.')
self.mock_logger.error.assert_called_once_with('asdf worker1 asdf')
开发者ID:hgschmie,项目名称:pulp,代码行数:6,代码来源:test_tasks.py
示例17: test_removes_all_associated_reserved_resource_entries
def test_removes_all_associated_reserved_resource_entries(self):
tasks._delete_worker('worker1')
self.assertTrue(self.mock_reserved_resource.objects.called)
remove = self.mock_reserved_resource.objects.return_value.delete
remove.assert_called_once_with()
开发者ID:zjhuntin,项目名称:pulp,代码行数:5,代码来源:test_tasks.py
示例18: test_criteria_to_find_task_status_is_correct
def test_criteria_to_find_task_status_is_correct(self):
tasks._delete_worker('worker1')
expected_call = mock.call(
filters={'worker_name': self.mock_worker.from_bson.return_value.name,
'state': {'$in': self.mock_constants.CALL_INCOMPLETE_STATES}})
self.assertEqual(self.mock_criteria.mock_calls[1], expected_call)
开发者ID:omps,项目名称:pulp,代码行数:6,代码来源:test_tasks.py
示例19: test_criteria_to_find_all_worker_is_correct
def test_criteria_to_find_all_worker_is_correct(self):
tasks._delete_worker('worker1')
self.assertEqual(self.mock_criteria.mock_calls[0], mock.call(filters={'_id': 'worker1'}))
开发者ID:AndreaGiardini,项目名称:pulp,代码行数:3,代码来源:test_tasks.py
示例20: sigterm_handler
def sigterm_handler(_signo, _stack_frame):
msg = _("Worker '%s' shutdown" % name)
_logger.info(msg)
tasks._delete_worker(name, normal_shutdown=True)
sys.exit(0)
开发者ID:pcreech,项目名称:pulp,代码行数:5,代码来源:app.py
注:本文中的pulp.server..tasks._delete_worker函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论