solo.py 767 B

1234567891011121314151617181920212223242526272829303132
  1. # -*- coding: utf-8 -*-
  2. """
  3. celery.concurrency.solo
  4. ~~~~~~~~~~~~~~~~~~~~~~~
  5. Single-threaded pool implementation.
  6. """
  7. from __future__ import absolute_import, unicode_literals
  8. import os
  9. from .base import BasePool, apply_target
  10. __all__ = ['TaskPool']
  11. class TaskPool(BasePool):
  12. """Solo task pool (blocking, inline, fast)."""
  13. body_can_be_buffer = True
  14. def __init__(self, *args, **kwargs):
  15. super(TaskPool, self).__init__(*args, **kwargs)
  16. self.on_apply = apply_target
  17. self.limit = 1
  18. def _get_info(self):
  19. return {'max-concurrency': 1,
  20. 'processes': [os.getpid()],
  21. 'max-tasks-per-child': None,
  22. 'put-guarded-by-semaphore': True,
  23. 'timeouts': ()}