Skip to content

Clean up param "workers" in WSGIMiddleware#1146

Merged
JayH5 merged 2 commits intoKludex:masterfrom
laggardkernel:bugfix/clean-wsgi-mw
Jun 13, 2021
Merged

Clean up param "workers" in WSGIMiddleware#1146
JayH5 merged 2 commits intoKludex:masterfrom
laggardkernel:bugfix/clean-wsgi-mw

Conversation

@laggardkernel
Copy link
Copy Markdown
Contributor

@laggardkernel laggardkernel commented Mar 3, 2021

Param workers in WSGIMiddleware.__init__ has not been used
since 0.6.3, which is changed in GH-164, commit 96c51c9.

We formerly used a ThreadPoolExecutor, which support setting worker numbers. Later it was changed to used the default executor.

# 0.5.2 2018-10-17 860fdf6c8b0eb88b9668153fdf2bf0352ec3152a

class WSGIMiddleware:
    def __init__(self, app: typing.Callable, workers: int = 10) -> None:
        self.app = app
        self.executor = ThreadPoolExecutor(max_workers=workers)

    async def __call__(self, receive: Receive, send: Send) -> None:
        ...
        wsgi = self.loop.run_in_executor(
            self.executor, self.wsgi, environ, self.start_response
        )


# 0.6.3 2018-10-31 96c51c959ae5592194f0b785a424e225cd4f4d3c

class WSGIMiddleware:
    ...
    async def __call__(self, receive: Receive, send: Send) -> None:
        # custom executor is dropped
        wsgi = self.loop.run_in_executor(
            None, self.wsgi, environ, self.start_response
        )

I don't think anyone is still using the "worker" param after more than 2 years. But out of caution, only made a DeprecationWarning first. Cause I'm not sure which is the correct time to obsolete this param in init, just gave a release number "1.0", which may need to be adjusted. The parameter was removed.

@laggardkernel laggardkernel force-pushed the bugfix/clean-wsgi-mw branch from 7165108 to 5f910c8 Compare March 3, 2021 15:21
@laggardkernel
Copy link
Copy Markdown
Contributor Author

laggardkernel commented Mar 3, 2021

I was just watching the code and finding how Starlette works, noticed there's a weird param "workers" not needed by any functions, and opened a pr.

I noticed a thumb down here. Sorry to submit such a trifling change. Maybe this pr is unnecessary cause the WSGIMiddleware.__init__ still works without the "workers" removed. Or maybe just better to notice anyone uses "workers" and tell them it had been dropped.

I'll handle the decision to the maintainers.

BTW, force pushed once to fix linting. The checks reported a coverage fail, not sure how it's related to my commit.

@JayH5
Copy link
Copy Markdown
Contributor

JayH5 commented Mar 11, 2021

Thanks for the PR. I think we can just remove this parameter since it hasn't actually done anything for a long time.

@JayH5 JayH5 added the clean up Refinement to existing functionality label Mar 11, 2021
Param "workers" in WSGIMiddleware.__init__ has not been used
since 0.6.3, which is changed in KludexGH-164, commit 96c51c.
@laggardkernel laggardkernel force-pushed the bugfix/clean-wsgi-mw branch from 5f910c8 to decb8e8 Compare June 13, 2021 10:31
@laggardkernel
Copy link
Copy Markdown
Contributor Author

Changed the fix to cleaning up.

@laggardkernel laggardkernel changed the title Deprecate param "workers" in WSGIMiddleware Clean up param "workers" in WSGIMiddleware Jun 13, 2021
@JayH5 JayH5 merged commit 310194e into Kludex:master Jun 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clean up Refinement to existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants