#How can i do this in a better way

8 messages · Page 1 of 1 (latest)

charred helm
#

I am trying to make some databse operations via tokio_postgress so in order to make it await i need to pass it under a async fn or a async closure

#

but while doing so i am getting error like this rs tokio::spawn(async move { 30 | | let cp = closure(Self::fetch_response(&mut i).await.unwrap().as_deref()).await; 31 | | Self::write_to_server(&mut i, cp).await 32 | | }); | |__________________^ future created by async block is not `Send` |

#

which makes sence that asyncFnMut is not Send as it can cause datarace

#

but i am making db calls

#

only

#

which i can protect with transactions

#

also please look into the Arc i am using should i use it in this way or someelse way