mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 14:35:36 +01:00
Write a clarifying comment on Tokio's stack size
This commit is contained in:
parent
8826733dbd
commit
cd3dcc1611
1 changed files with 6 additions and 1 deletions
|
@ -410,7 +410,12 @@ where
|
||||||
|
|
||||||
let stop_token = Some(update_listener.stop_token());
|
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 || {
|
scope.spawn(move || {
|
||||||
let runtime = tokio::runtime::Builder::new_multi_thread()
|
let runtime = tokio::runtime::Builder::new_multi_thread()
|
||||||
.thread_stack_size(self.stack_size)
|
.thread_stack_size(self.stack_size)
|
||||||
|
|
Loading…
Reference in a new issue