Skip to content

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

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

Davixk wants to merge 2 commits 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.

@codecov

codecov Bot commented Sep 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.75%. Comparing base (ced1909) to head (3b7d32e).
⚠️ Report is 6 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #660      +/-   ##
==========================================
+ Coverage   82.49%   83.75%   +1.25%     
==========================================
  Files          69       69              
  Lines        2697     2702       +5     
==========================================
+ Hits         2225     2263      +38     
+ Misses        472      439      -33     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

2 participants