Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Splitting FastAPI endpoints file into ~8 separate files makes wiring slow #879

Unanswered
dandiep asked this question in Q&A
Discussion options

I had a single endpoints.py file with all my endpoints in it, but it got to be unmaintainable. So I split it into several files. Now I load it this way:

 # Get all submodules in the endpoints package
 endpoint_modules = []
 for _, name, _ in pkgutil.iter_modules(jetway.endpoints.__path__, jetway.endpoints.__name__ + "."):
 try:
 endpoint_modules.append(importlib.import_module(name))
 except ImportError:
 pass
 logger.info("Wiring services...")
 container.wire(
 modules=endpoint_modules
 + [
 __name__,
 ]
 )

The problem is that wiring went from ~1 sec to ~2.5 on my MacBook Pro M2! No logic changed.

Any ideas what is going on or steps on how to debug? 2.5 seconds to wire everything seems super slow...

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /