Skip to content

Commit db49b4a

Browse files
authored
Don't delay starting first batch of shards (#3327)
Moves the check for `ShardManagerMessage` to the end of the `ShardManager::run` loop. This avoids unnecessarily waiting `wait_time_between_shard_start` once before ever starting shards.
1 parent fce19bb commit db49b4a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/gateway/sharding/shard_manager.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ impl ShardManager {
142142
) -> Result<(), GatewayError> {
143143
self.initialize(shard_index, shard_init, shard_total);
144144
loop {
145+
let batch = self.queue.pop_batch();
146+
self.checked_start(batch).await;
147+
145148
if let Ok(Some(msg)) =
146149
timeout(self.wait_time_between_shard_start, self.manager_rx.next()).await
147150
{
@@ -150,8 +153,6 @@ impl ShardManager {
150153
ShardManagerMessage::Quit(res) => return res,
151154
}
152155
}
153-
let batch = self.queue.pop_batch();
154-
self.checked_start(batch).await;
155156
}
156157
}
157158

0 commit comments

Comments
 (0)