Tokio Time vs Core Time for query.wait()
Closed this issue · 2 comments
The wait method on query is documented as taking core::time::Duration. Can I / should I use the tokio::time::Duration here, and what are the effects in terms of yielding a thread vs. blocking (I would like to avoid blocking). Sorry I'm still wrapping my head around async w/Tokio.
The waiting via Tokio isn't a blocking call so don't worry about that aspect. Yes that particular call will wait but other Async operations can still happen concurrently.
I don't remember which duration it wants off the top of my head but I think it should accept either.
I just checked and Tokio uses core::time::Duration
anyway (and std::time::Duration
is also just the same one).
Have a read of the async book for more details on blocking vs non-blocking in an async context: https://rust-lang.github.io/async-book/01_getting_started/01_chapter.html
There are no blocking operations in thirtyfour
so don't worry about that aspect so much when trying to automate a browser. If you call .await
after each call then things will run in series anyway. If you need to run things in parallel, use Tokio's join!
or select!
macros. This is explained fairly well in the async book here: https://rust-lang.github.io/async-book/06_multiple_futures/01_chapter.html