Skip to content

feat(cli): add event loop factory option - #660

Open
Davixk wants to merge 1 commit into
taskiq-python:masterfrom
Davixk:feat/cli-loop-factory
Open

feat(cli): add event loop factory option#660
Davixk wants to merge 1 commit into
taskiq-python:masterfrom
Davixk:feat/cli-loop-factory

Conversation

@Davixk

@Davixk Davixk commented Aug 18, 2026

Copy link
Copy Markdown

Closes #659.

Summary

  • add --loop-factory module:callable to the worker and scheduler CLI
  • resolve and validate the configured factory before creating an event loop
  • resolve worker factories inside each worker subprocess
  • let an explicit worker factory override automatic uvloop selection
  • preserve existing behavior when no factory is configured
  • document the option for both commands

Motivation

Some integrations require a specific event loop implementation. For example, async Psycopg on Windows requires a selector-based loop instead of the default ProactorEventLoop.

Applications can currently influence TaskIQ-created loops through process-wide asyncio policies, but those policies are deprecated in Python 3.14 and scheduled for removal in Python 3.16.

This provides a generic application-controlled mechanism and a forward-compatible alternative for the Windows compatibility case discussed in #641, without changing TaskIQ's default loop on any platform.

Compatibility

The scheduler uses AnyIO's loop_factory backend option so the feature remains compatible with TaskIQ's Python 3.10 minimum. The worker keeps its existing loop lifecycle and changes only how the loop is selected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add configurable event loop factories to worker and scheduler CLI

1 participant