Start the periodic cookie refresh background task. Returns: The created asyncio task, or None if refresh is disabled.
()
| 177 | |
| 178 | |
| 179 | def start_periodic_refresh() -> Optional[asyncio.Task]: |
| 180 | """ |
| 181 | Start the periodic cookie refresh background task. |
| 182 | |
| 183 | Returns: |
| 184 | The created asyncio task, or None if refresh is disabled. |
| 185 | """ |
| 186 | global _periodic_task |
| 187 | |
| 188 | if not COOKIE_REFRESH_ENABLED: |
| 189 | logger.info("Cookie refresh is disabled, not starting periodic task") |
| 190 | return None |
| 191 | |
| 192 | if _periodic_task is not None and not _periodic_task.done(): |
| 193 | logger.warning("Periodic refresh task already running") |
| 194 | return _periodic_task |
| 195 | |
| 196 | _periodic_task = asyncio.create_task(_periodic_refresh_loop()) |
| 197 | return _periodic_task |
| 198 | |
| 199 | |
| 200 | async def stop_periodic_refresh(): |
no test coverage detected