Skip to content

Commit

Permalink
Avoid dropping TaskList, to avoid blocking executor thread in drop ha…
Browse files Browse the repository at this point in the history
…ndler
  • Loading branch information
jbearer committed Oct 11, 2024
1 parent bfae117 commit b0f03b9
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions sequencer/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ impl<N: ConnectedNetwork<PubKey>, P: SequencerPersistence, V: Versions> Sequence
let events = handle.event_stream();

let node_id = node_state.node_id;
let mut ctx = Self {
let ctx = Self {
handle: Arc::new(RwLock::new(handle)),
state_signer: Arc::new(state_signer),
tasks: Default::default(),
Expand All @@ -210,23 +210,21 @@ impl<N: ConnectedNetwork<PubKey>, P: SequencerPersistence, V: Versions> Sequence
node_state,
config,
};
ctx.spawn(
"proposal fetcher",
fetch_proposals(ctx.handle.clone(), persistence.clone()),
);
ctx.spawn(
"main event handler",
handle_events(
node_id,
events,
persistence,
ctx.state_signer.clone(),
external_event_handler,
Some(event_streamer.clone()),
event_consumer,
anchor_view,
),
);

// Spawn event handling loops. These can run in the background (detached from `ctx.tasks`
// and thus not explicitly cancelled on `shut_down`) because they each exit on their own
// when the consensus event stream ends.
spawn(fetch_proposals(ctx.handle.clone(), persistence.clone()));
spawn(handle_events(
node_id,
events,
persistence,
ctx.state_signer.clone(),
external_event_handler,
Some(event_streamer.clone()),
event_consumer,
anchor_view,
));

ctx
}
Expand Down Expand Up @@ -437,6 +435,7 @@ async fn fetch_proposals<N, P, V>(
),
);
}
tasks.shut_down().await;
}

#[tracing::instrument(skip(consensus, persistence))]
Expand Down

0 comments on commit b0f03b9

Please sign in to comment.