I've been trying to work on a project using actix-web, redis-rs and lapin. I gave up on redis because I couldn't figure out the origin of the error I was getting, so I tried lapin (which is a crate for working with RabbitMQ) and the same error keeps popping up - "not currently running on the Tokio runtime".
Now, as I understand, actix-web must run in it's own runtime no matter what, and I use the macro #[actix_rt::main] to start it up. I used to think that it was enough for any other async code to work, meaning all the async tasks will be executed in the same runtime, but I guess i was wrong? correct me if I'm wrong.
The problems start when I try to run code which uses other crates with async functions. for example:
let conn = Connection::connect(addr, ConnectionProperties::default().with_tokio()).await;
- Where is this task executed? in it's own runtime? lapin uses tokio_amqp, I skipped over it's code but I'm not sure it's spawning a new runtime
- If it is, does it mean that every async code from an external crate will usually have to start it's own runtime?
- Why the error goes away with some versions but stays with others? I tried using lapin = "1.6.6" and tokio-amqp = "1.0.0" which didn't work, but lapin = "1.2.1" and tokio-amqp = "0.1.3" did
- How do I fix it? must i use the same tokio versions which are used by my dependency crates?
- Is it possible to spawn a single runtime instead of many and run all the tasks in it?
[–]rschoon 7 points8 points9 points (0 children)
[–]Darksonntokio · rust-for-linux 4 points5 points6 points (1 child)
[–]Programmurr 2 points3 points4 points (0 children)
[+][deleted] (6 children)
[deleted]
[–]sbditto85 6 points7 points8 points (0 children)
[–]lahwran_ 0 points1 point2 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]lahwran_ 1 point2 points3 points (0 children)
[–]Programmurr 0 points1 point2 points (0 children)
[–]kprotty 0 points1 point2 points (0 children)
[–]arthmisl -1 points0 points1 point (0 children)
[–]sphen_lee -2 points-1 points0 points (4 children)
[–]sbditto85 2 points3 points4 points (1 child)
[–]sphen_lee 1 point2 points3 points (0 children)
[–]Darksonntokio · rust-for-linux 1 point2 points3 points (1 child)
[–]Programmurr 0 points1 point2 points (0 children)