solo.py 706 B

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