Comments (20)
Line 170 in 395cf69
from ntex.
you can try to modify System builder and allow to run it with tokio’s Handler
from ntex.
I quickly look into pr. I don't really understand how shuttle work. technically, ntex should be similar to Actix, but I am not sure how Actix works nowadays. as I remember Actix team decided tight connect Actix and Tokio, on other hand ntex is as neutral as possible, so you might need to construct Tokio runtime via ntex. unfortunately, I don't have much free time to invest
from ntex.
I quickly look into pr. I don't really understand how shuttle work. technically, ntex should be similar to Actix, but I am not sure how Actix works nowadays. as I remember Actix team decided tight connect Actix and Tokio, on other hand ntex is as neutral as possible, so you might need to construct Tokio runtime via ntex. unfortunately, I don't have much free time to invest
Just one question, when you say "construct Tokio runtime" could you explain a bit more what you mean? I am just trying to identify the root cause so that I can resolve it :)
from ntex.
someone needs to construct tokio runtime, i dont see this in your pr. all async operations must run from within
from ntex.
Cool thank you very much for your time and insights. I will try to look deeper into it!
from ntex.
@fafhrd91 I have given it a try but apparently since I can get an access to Shuttle's runtime with Handle::current
, while I cannot pass it to Ntex
I cannot think of a way to avoid having Ntex
creating a new runtime and essentially panicking. Am I thinking it wrong?
from ntex.
Also from what I have been reading about Actix's similar documentation, the behaviour between Ntex and Actix looks similar, regarding LocalSet
etc!
from ntex.
you can try to modify System builder and allow to run it with tokio’s Handler
You mean by submitting a PR to Ntex to add that feature, right?
from ntex.
you can try to modify System builder and allow to run it with tokio’s Handler
You mean by submitting a PR to Ntex to add that feature, right?
right, but just for tokio feature. i dont want to depend on tokio in mid term
from ntex.
you can try to modify System builder and allow to run it with tokio’s Handler
You mean by submitting a PR to Ntex to add that feature, right?
right, but just for tokio feature. i dont want to depend on tokio in mid term
Ok got it, I will give it a try but since I am new to Rust, I might struggle a bit 😄
from ntex.
@fafhrd91 I have opened this. Am I towards a totally wrong direction? #336
from ntex.
use ntex::rt::System::new("main").run_local(async {})
in your pr
from ntex.
Amazing! Thank you very much @fafhrd91 ❤️
from ntex.
use
ntex::rt::System::new("main").run_local(async {})
in your pr
@fafhrd91 I cannot find the run_local
method in the docs for SystemRunner
.
from ntex.
this method available only for tokio feature, probably docs gen params needs to be adjusted
from ntex.
@fafhrd91 Thanks!
How can we run async jobs in the background? I have tried
System::new("scheduler")
.system()
.arbiter()
.spawn(Box::pin(async move {
loop {
scheduler.tick().await;
// Cannot use `std::thread::sleep` because it blocks the Tokio runtime.
time::sleep(scheduler.time_till_next_job()).await;
}
}));
But it does not work as expected. The code is from our integration with ntex.
from ntex.
ntex_rt::spawn(some_fut)
from ntex.
ntex_rt::spawn(some_fut)
It returns an error:
`spawn_local` called from outside of a `task::LocalSet`
from ntex.
you have to pass System::current() from block_on. and the use System::arbiter().spawn()
here is example
Line 27 in c60e7f5
from ntex.
Related Issues (20)
- Please respect semantic versioning HOT 1
- 23Q4 Performance Regressions as Revealed in TechEmpower Results HOT 5
- compilation error below, how to resolve? HOT 2
- async-graphql integration example? HOT 2
- `ntex::time::timeout` is not accurate HOT 3
- [Bug] Unable to set length manually HOT 4
- Moving websocket to a feature HOT 3
- [ntex-server](Bug) Duplicates ctrlc_handler registration under win causing process crash HOT 2
- Program panicks upon ctrl+c HOT 3
- Wrong feature gate in ntex/ntex-net/src/compat.rs HOT 1
- How to convert web::types::Payload to AsyncRead HOT 1
- Is there a feature comparison with other frameworks ? HOT 1
- The `insert` method for `Extensions` does not return existed value HOT 1
- Compilation failed for windows HOT 2
- http client closes h2 connection HOT 1
- Can't access state in middleware HOT 6
- Ntex is a masterpiece ! SALUTE !!
- Causing the socket to not close HOT 5
- Help: How to return errors during serde serialization and deserialization HOT 2
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 ntex.