5 ms·
Shouldn’t any route that interacts with the file system (including anything that calls render_template) be a sync (non-async) route? Doesn’t blocking io complet
by skinner927 3y ago
Shouldn’t any route that interacts with the file system (including anything that calls render_template) be a sync (non-async) route? Doesn’t blocking io completely destroy any performance gain from async? If so, why do the examples in the docs show this pattern?
- peller 3y agoIO is blocking within that request. There's no way around that. The difference between sync and async is that with the latter, the event loop from the blocking request is freed up to handle other requests, which is where the performance gain is. If there's only a single request, then sync and async are going to look largely the same from the outside. However if there's thousands of requests, async is going to do much better.
- manvillej 3y agoyup! I think of it like cooking. If you're only cooking one thing, sync & async look the same. But if you're cooking several things, you can switch between dishes as needed (asynchronous) instead of cooking each dish one at a time (synchronous)
- last_responder 3y agoI had the exact same question. Some of those docs seem much akin to how to draw an owl” with no real explanation how to solve the issues.