| 136 | w.pool.terminate() |
| 137 | |
| 138 | def create(self, w): |
| 139 | semaphore = None |
| 140 | max_restarts = None |
| 141 | if w.app.conf.worker_pool in GREEN_POOLS: # pragma: no cover |
| 142 | warnings.warn(UserWarning(W_POOL_SETTING)) |
| 143 | threaded = not w.use_eventloop or IS_WINDOWS |
| 144 | procs = w.min_concurrency |
| 145 | w.process_task = w._process_task |
| 146 | if not threaded: |
| 147 | semaphore = w.semaphore = LaxBoundedSemaphore(procs) |
| 148 | w._quick_acquire = w.semaphore.acquire |
| 149 | w._quick_release = w.semaphore.release |
| 150 | max_restarts = 100 |
| 151 | if w.pool_putlocks and w.pool_cls.uses_semaphore: |
| 152 | w.process_task = w._process_task_sem |
| 153 | allow_restart = w.pool_restarts |
| 154 | pool = w.pool = self.instantiate( |
| 155 | w.pool_cls, w.min_concurrency, |
| 156 | initargs=(w.app, w.hostname), |
| 157 | maxtasksperchild=w.max_tasks_per_child, |
| 158 | max_memory_per_child=w.max_memory_per_child, |
| 159 | timeout=w.time_limit, |
| 160 | soft_timeout=w.soft_time_limit, |
| 161 | putlocks=w.pool_putlocks and threaded, |
| 162 | lost_worker_timeout=w.worker_lost_wait, |
| 163 | threads=threaded, |
| 164 | max_restarts=max_restarts, |
| 165 | allow_restart=allow_restart, |
| 166 | forking_enable=True, |
| 167 | semaphore=semaphore, |
| 168 | sched_strategy=self.optimization, |
| 169 | app=w.app, |
| 170 | ) |
| 171 | _set_task_join_will_block(pool.task_join_will_block) |
| 172 | return pool |
| 173 | |
| 174 | def info(self, w): |
| 175 | return {'pool': w.pool.info if w.pool else 'N/A'} |