webargs icon indicating copy to clipboard operation
webargs copied to clipboard

Optionally use a ThreadPoolExecutor for schema validation and json loading when using aiohttp

Open dnp1 opened this issue 7 years ago • 1 comments

Parse Json and validate schemas are CPU bound tasks. Parse and validate long bodies can impact the reactivity of the event loop.

Use a ThreadPoolExecutor is a simple and eficient solution.

However, isn't trivial use your packed solution aside a ThreadPoolExecutor, because it neeeds function independent from the event loop.

Currently, I dropped the use_args decorator and I am using my own implemented decorator.

But I would like using it again.

Why not allow the user provide a executor?

dnp1 avatar Aug 03 '18 15:08 dnp1

I'm open to this if it doesn't add too much complexity to the codebase. Rather than adding a parameter to provide an executor, I think I'd prefer exposing functions (parse_json, etc.) that could be passed to run_in_executor. PRs welcome.

sloria avatar Jan 11 '19 00:01 sloria