ISSUE - potential lock issue
All checks were successful
ci/woodpecker/pr/cargo-checks Pipeline was successful
All checks were successful
ci/woodpecker/pr/cargo-checks Pipeline was successful
This commit is contained in:
parent
66195138f8
commit
b5e95668a5
2 changed files with 87 additions and 44 deletions
|
@ -1104,7 +1104,9 @@ impl Routine {
|
|||
|
||||
// [x] execution body
|
||||
// trg_routine_ar.read().await.loopbody().await;
|
||||
trg_routine_ar.write().await.loopbody().await;
|
||||
{
|
||||
trg_routine_ar.write().await.loopbody().await;
|
||||
}
|
||||
|
||||
|
||||
{ // [x] End of Loop iteration
|
||||
|
|
|
@ -152,34 +152,44 @@ async fn countdown_chnl_v1(params : ExecBodyParams) {
|
|||
|
||||
async fn innertester(params : ExecBodyParams) {
|
||||
|
||||
{
|
||||
let curract_guard = params.curr_act.read().await;
|
||||
|
||||
|
||||
let logmsg_botact = match *params.curr_act.read().await {
|
||||
BotAction::C(_) => "command",
|
||||
BotAction::R(_) => "routine",
|
||||
BotAction::L(_) => "listener",
|
||||
} ;
|
||||
// let logmsg_botact = match *params.curr_act.read().await {
|
||||
|
||||
let logmsg_botact = match *curract_guard {
|
||||
BotAction::C(_) => "command",
|
||||
BotAction::R(_) => "routine",
|
||||
BotAction::L(_) => "listener",
|
||||
} ;
|
||||
|
||||
botlog::trace(
|
||||
format!("Params > Curr_act type : {:?}", logmsg_botact).as_str(),
|
||||
Some("Experiments003 > countdown_chnl()".to_string()),
|
||||
Some(¶ms.msg),
|
||||
);
|
||||
Log::flush();
|
||||
|
||||
let bot = Arc::clone(¶ms.bot);
|
||||
|
||||
let botlock = bot.read().await;
|
||||
|
||||
if let BotAction::R(arr) = &*params.curr_act.read().await {
|
||||
|
||||
botlog::trace(
|
||||
"Before loading remaining iterations",
|
||||
format!("Params > Curr_act type : {:?}", logmsg_botact).as_str(),
|
||||
Some("Experiments003 > countdown_chnl()".to_string()),
|
||||
None,
|
||||
Some(¶ms.msg),
|
||||
);
|
||||
Log::flush();
|
||||
}
|
||||
|
||||
{
|
||||
let bot = Arc::clone(¶ms.bot);
|
||||
let botlock = bot.read().await;
|
||||
|
||||
let curract_guard = params.curr_act.write().await;
|
||||
|
||||
// let routine_lock = arr.write().await;
|
||||
|
||||
if let BotAction::R(arr) = &*curract_guard {
|
||||
// if let BotAction::R(arr) = &*params.curr_act.read().await {
|
||||
|
||||
botlog::trace(
|
||||
"Before loading remaining iterations",
|
||||
Some("Experiments003 > countdown_chnl()".to_string()),
|
||||
None,
|
||||
);
|
||||
Log::flush();
|
||||
|
||||
|
||||
// let iterleft = arr.read().await.remaining_iterations.unwrap_or(0);
|
||||
|
@ -197,10 +207,10 @@ async fn countdown_chnl_v1(params : ExecBodyParams) {
|
|||
// }
|
||||
|
||||
{
|
||||
let routine_lock = arr.write().await;
|
||||
let a = routine_lock.remaining_iterations;
|
||||
println!("remaining iterations : {:?}", a);
|
||||
}
|
||||
let routine_lock = arr.write().await;
|
||||
let a = routine_lock.remaining_iterations;
|
||||
println!("remaining iterations : {:?}", a);
|
||||
}
|
||||
|
||||
botlog::trace(
|
||||
"after loading remaining iterations",
|
||||
|
@ -251,9 +261,12 @@ async fn countdown_chnl_v1(params : ExecBodyParams) {
|
|||
// chosen_channel.0.clone(),
|
||||
// outmsg,
|
||||
// params.clone()
|
||||
|
||||
|
||||
// ).await;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -361,27 +374,55 @@ async fn test3_body(params : ExecBodyParams) {
|
|||
async fn rtestbody(params : ExecBodyParams) {
|
||||
|
||||
|
||||
let logmsg_botact = match *params.curr_act.read().await {
|
||||
BotAction::C(_) => "command",
|
||||
BotAction::R(_) => "routine",
|
||||
BotAction::L(_) => "listener",
|
||||
} ;
|
||||
let guard = params.curr_act.read().await;
|
||||
{
|
||||
let logmsg_botact = match *guard {
|
||||
BotAction::C(_) => "command",
|
||||
BotAction::R(_) => "routine",
|
||||
BotAction::L(_) => "listener",
|
||||
} ;
|
||||
|
||||
botlog::trace(
|
||||
format!("Params > Curr_act type : {:?}", logmsg_botact).as_str(),
|
||||
Some("Experiments003 > test3 command body".to_string()),
|
||||
Some(¶ms.msg),
|
||||
);
|
||||
Log::flush();
|
||||
botlog::trace(
|
||||
format!("Params > Curr_act type : {:?}", logmsg_botact).as_str(),
|
||||
Some("Experiments003 > test3 command body".to_string()),
|
||||
Some(¶ms.msg),
|
||||
);
|
||||
Log::flush();
|
||||
}
|
||||
|
||||
if let BotAction::R(arr) = &*params.curr_act.read().await {
|
||||
for curriter in 0..5 {
|
||||
println!("tester - Routine - Completed Iterations : {}",
|
||||
arr.read().await.complete_iterations);
|
||||
println!("tester - Custom Loop - Completed Iterations : {}",
|
||||
curriter);
|
||||
sleep(Duration::from_secs_f64(0.5)).await;
|
||||
|
||||
{
|
||||
let logmsg_botact = match *guard {
|
||||
BotAction::C(_) => "command 2",
|
||||
BotAction::R(_) => "routine 2",
|
||||
BotAction::L(_) => "listener 2",
|
||||
} ;
|
||||
|
||||
botlog::trace(
|
||||
format!("Params > Curr_act type : {:?}", logmsg_botact).as_str(),
|
||||
Some("Experiments003 > test3 command body".to_string()),
|
||||
Some(¶ms.msg),
|
||||
);
|
||||
Log::flush();
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
println!("Critical code area start"); // <= 03.29 - This is printed
|
||||
if let BotAction::R(c) = &*guard {
|
||||
println!("{:?}",c.read().await.channel);
|
||||
}
|
||||
println!("Critical code area end"); // <= 03.29 - ISSUE This is NOT printed
|
||||
|
||||
// if let BotAction::R(arr) = &*params.curr_act.read().await {
|
||||
// for curriter in 0..5 {
|
||||
// println!("tester - Routine - Completed Iterations : {}",
|
||||
// arr.read().await.complete_iterations);
|
||||
// println!("tester - Custom Loop - Completed Iterations : {}",
|
||||
// curriter);
|
||||
// sleep(Duration::from_secs_f64(0.5)).await;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue