Write a clarifying comment on Tokio's stack size

This commit is contained in:
Lewis Pearson 2024-10-21 19:39:26 -04:00
parent 8826733dbd
commit cd3dcc1611
No known key found for this signature in database
GPG key ID: F0C33B48BD883C81

View file

@ -410,7 +410,12 @@ where
let stop_token = Some(update_listener.stop_token());
std::thread::scope(|scope| {
// We create a new Tokio runtime in order to set the correct stack size. We do
// it a scoped thread because Tokio runtimes cannot be nested. We need a scoped
// thread because of the lifetime `'a` in `&'a mut self` and because scoped
// threads are automatically joined. See this issue:
// <https://github.com/teloxide/teloxide/issues/1154>.
std::thread::scope(|scope: &std::thread::Scope<'_, '_>| {
scope.spawn(move || {
let runtime = tokio::runtime::Builder::new_multi_thread()
.thread_stack_size(self.stack_size)