Skip to content

SQLx from a function? #440

Discussion options

You must be logged in to vote

Solution for those seeking is to use Tokio's handle. Possible through a static once_cell. And then spawn an async thread to do the task you want.

this stackoverflow thread can be helpful: https://stackoverflow.com/questions/61292425/how-to-run-an-asynchronous-task-from-a-non-main-thread-in-tokio

Replies: 2 comments 15 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by ElhamAryanpur
Comment options

You must be logged in to vote
15 replies
@cheesycod
Comment options

@khvzak
Comment options

@khvzak
Comment options

@ElhamAryanpur
Comment options

@ElhamAryanpur
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants