Comments (2)
Hi there! I'm encountering the same problem. As an additional detail I could add that the same crash happen when ctx.notify_later
is used. It seems like both ctx.notify_later
and ctx.run_internval
crashed due to access to tokio::runtime::Handle::current()
.
Crash is also happen when directly accessing current tokio handle:
use actix::prelude::*;
struct MyActor;
impl Actor for MyActor {
type Context = Context<Self>;
fn started(&mut self, ctx: &mut Self::Context) {
tokio::runtime::Handle::current(); // will be paniced
}
}
fn main() {
let system = actix::System::new();
system.block_on(async {
MyActor.start();
// Next line fixes panic when uncommented:
// tokio::task::yield_now().await;
});
}
from actix.
I believe this is caused by the Drop
implementation of ContextFut
:
actix/actix/src/contextimpl.rs
Lines 219 to 232 in d7aab0a
The poll will call your started
function if ContextFut
didn't get the change to be polled before. The thing is, tokio
drops its spawned futures after shutting down the runtime, run_interval
will try to create a Sleep
instance from tokio
and then panic.
The Drop
implementation is arguably wrong, the poll can run arbitrary code provided by the user (through started
, stopping
and stopped
), and it's understandable that the user will assume that a tokio
runtime exists in at least some of these methods.
from actix.
Related Issues (20)
- Panic in Arbiter thread HOT 1
- Fair handling of async sub-tasks in ContextFut
- async and sync clash in `started` trying to `send` to other actor HOT 3
- Implement PartialEq and Eq for WeakAddr
- unable to retrieve actor addresses from registry outside of actor context HOT 1
- Question: How to wait for an event on actor startup? HOT 1
- Add discord link instead of gitter HOT 1
- Actor stops receiving messages after filling the mailbox HOT 4
- Payload reached size limit. HOT 1
- Conditional inclusion of tokio-net and tokio-signal for targets that do not support them. HOT 3
- "PAGE NOT FOUND" when open the book
- Readme User Guide link is broken HOT 1
- AsyncContext::wait() is not actually waiting HOT 2
- Consider updating `actix-derive` to use `syn@2` HOT 2
- Docs: Broken links in README.md (minor issue)
- Hey,all,I have one question. HOT 2
- Question: Awaiting actor responses in message handler HOT 1
- Build fail due to "ahash v0.7.7" error[E0635]: unknown feature stdsimd HOT 1
- Fine-tune the Ordering for num_senders HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from actix.