Skip to content

Conversation

@MIvanchev
Copy link

No description provided.

@MIvanchev MIvanchev force-pushed the rem-needless-task branch 2 times, most recently from a086dde to bdf8fea Compare December 31, 2025 09:19
@matze
Copy link
Owner

matze commented Jan 1, 2026

Why do you think it's unnecessary?

@MIvanchev
Copy link
Author

It starts a task and blocks while it runs so I thought it's some kinda of a mistake or a left over.

@matze
Copy link
Owner

matze commented Jan 1, 2026

It's exactly the opposite. spawn_blocking takes synchronous code that would block the executor and make it async-aware by moving it onto a separate dedicated thread for CPU-bound work.

@MIvanchev
Copy link
Author

But you then sync it back in so nothing is won or I'm understanding something very false?

@matze
Copy link
Owner

matze commented Jan 1, 2026

If you mean "sync it back" making it .await then no, that yields back to the executor and some other future or task can proceed. If we were to block the CPU and thus the executor when highlighting (which can be expensive) then no one else could make progress. This is a good article on that topic.

@MIvanchev
Copy link
Author

Oh, ok, this is most probably entirely meaningless in that case :) Thanks!

@MIvanchev MIvanchev closed this Jan 1, 2026
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.

2 participants