async def async_run(self): w = worker.Worker(idle_sleep_time=0.42 if RECORD else 0.01) w.start() while self._running.is_set(): await asyncio.sleep(0.42 if RECORD else 0.02) w.stop() await w.wait_shutdown_complete()
async def run_worker(test_timeout=10, **kwargs): w = worker.Worker(**kwargs) w.start() started_at = time.monotonic() while (w._redis_stream is None or (await w._redis_stream.zcard("streams")) > 0) and time.monotonic() - started_at < test_timeout: await asyncio.sleep(0.5) w.stop() await w.wait_shutdown_complete()
async def run_worker(): w = worker.Worker() w.start() timeout = 10 started_at = time.monotonic() while (w._redis is None or (await w._redis.zcard("streams")) > 0 ) and time.monotonic() - started_at < timeout: await asyncio.sleep(0.5) w.stop() await w.wait_shutdown_complete()
async def _async_run_workers(): w = worker.Worker(idle_sleep_time=0.42 if RECORD else 0.01, enabled_services=["stream"]) w.start() timeout = 10 started_at = time.monotonic() while (w._redis is None or (await w._redis.zcard("streams")) > 0 ) and time.monotonic() - started_at < timeout: await asyncio.sleep(0.42 if RECORD else 0.02) w.stop() await w.wait_shutdown_complete()
async def run_engine(self) -> None: LOG.log(42, "RUNNING ENGINE") w = worker.Worker(enabled_services=set()) await w.start() while w._redis_stream is None or (await w._redis_stream.zcard("streams")) > 0: await w.shared_stream_worker_task(0) await w.dedicated_stream_worker_task(config.TESTING_ORGANIZATION_ID) w.stop() await w.wait_shutdown_complete()
async def _async_run_workers(timeout): w = worker.Worker(idle_sleep_time=0.42 if RECORD else 0.01, enabled_services=["stream"]) w.start() started_at = None while True: if w._redis is None or (await w._redis.zcard("streams")) > 0: started_at = None elif started_at is None: started_at = time.monotonic() elif time.monotonic() - started_at >= timeout: break await asyncio.sleep(timeout) w.stop() await w.wait_shutdown_complete()
async def run_full_engine(self) -> None: LOG.log(42, "RUNNING FULL ENGINE") w = worker.Worker( idle_sleep_time=self.WORKER_IDLE_SLEEP_TIME if RECORD else 0.01, enabled_services={ "shared-stream", "dedicated-stream", "delayed-refresh" }, delayed_refresh_idle_time=0.01, dedicated_workers_spawner_idle_time=0.01, dedicated_workers_syncer_idle_time=0.01, ) await w.start() # Ensure delayed_refresh and monitoring task run at least once await asyncio.sleep(self.WORKER_HAS_WORK_INTERVAL_CHECK) while (await w._redis_links.stream.zcard("streams") ) > 0 or self.worker_concurrency_works > 0: await asyncio.sleep(self.WORKER_HAS_WORK_INTERVAL_CHECK) w.stop() await w.wait_shutdown_complete()