Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow passing Tokio Handle on ntex-rt #336

Conversation

pavlospt
Copy link
Contributor

@pavlospt pavlospt commented Apr 2, 2024

No description provided.

@pavlospt pavlospt mentioned this pull request Apr 2, 2024
@fafhrd91
Copy link
Member

fafhrd91 commented Apr 3, 2024

idea is right, but I would make "handle: Option", and added ".new_with_handle(..)" methods.

@fafhrd91
Copy link
Member

fafhrd91 commented Apr 3, 2024

as I remember you can use Handle::new() instead of actual handle.

@pavlospt
Copy link
Contributor Author

pavlospt commented Apr 3, 2024

as I remember you can use Handle::new() instead of actual handle.

I wasn't able to find a Handle::new() 🤔

@pavlospt pavlospt force-pushed the chore/allow-system-builder-to-get-tokio-handle branch 2 times, most recently from 56ddf56 to 758fa37 Compare April 3, 2024 13:45
@fafhrd91
Copy link
Member

fafhrd91 commented Apr 3, 2024

@pavlospt
Copy link
Contributor Author

pavlospt commented Apr 3, 2024

https://docs.rs/tokio/latest/tokio/runtime/struct.Handle.html#method.current

Indeed ::current() is what I use in tests. Maybe you mean something else?

@pavlospt pavlospt force-pushed the chore/allow-system-builder-to-get-tokio-handle branch from 758fa37 to 420381c Compare April 3, 2024 13:56
@fafhrd91
Copy link
Member

fafhrd91 commented Apr 3, 2024

use current(), and something like use_current_handle: bool in builder

@pavlospt pavlospt force-pushed the chore/allow-system-builder-to-get-tokio-handle branch from 420381c to 82be8c5 Compare April 3, 2024 14:51
@pavlospt
Copy link
Contributor Author

pavlospt commented Apr 3, 2024

I have some tests that take longer than 60s on Ntex-rt and they fail with timeout. I believe I have reached the peak of my understanding of how the underlying system works here 😛 If you have more hints or advice let me know :D

@fafhrd91
Copy link
Member

fafhrd91 commented Apr 3, 2024

add env_logger::init() to your test and try to run it with RUST_LOG=trace

@pavlospt pavlospt force-pushed the chore/allow-system-builder-to-get-tokio-handle branch 2 times, most recently from 9049c36 to 0134187 Compare April 3, 2024 15:57
@pavlospt
Copy link
Contributor Author

pavlospt commented Apr 3, 2024

I have tried that and also tried debugging it. It seems that the other test is panicking because it cannot find a configured runtime and panics at: lib.rs#353. I am not sure how to enable tokio feature for this test and I am out of ideas :/

@fafhrd91
Copy link
Member

fafhrd91 commented Apr 3, 2024

default behavior must be same as before, running with handler must be enabled explicitly

@pavlospt
Copy link
Contributor Author

pavlospt commented Apr 3, 2024

But if this is not enabled with a Cargo feature then how am I going to import Handle 🤔 ?

@fafhrd91
Copy link
Member

fafhrd91 commented Apr 3, 2024

you can use try_current(), if it returns error then switch to old behavior

@pavlospt
Copy link
Contributor Author

pavlospt commented Apr 3, 2024

Handle though resides in tokio crate. So if tokio feature is not enabled then how will the library compile when it needs to

use tok_io::runtime::Handle;

🤔

@fafhrd91
Copy link
Member

fafhrd91 commented Apr 3, 2024

mark import with feature or move it inside block that already marked with feature

@pavlospt pavlospt force-pushed the chore/allow-system-builder-to-get-tokio-handle branch from 0134187 to 0ca1df6 Compare April 3, 2024 16:36
@pavlospt pavlospt force-pushed the chore/allow-system-builder-to-get-tokio-handle branch from 0ca1df6 to e73a699 Compare April 3, 2024 16:37
@pavlospt
Copy link
Contributor Author

pavlospt commented Apr 3, 2024

Ok I am now thinking this issue is above my skills with the language 😛 Thank for your time and your explanations though 🙏🏻

@fafhrd91
Copy link
Member

fafhrd91 commented Apr 3, 2024

I will take check what I can do next weekend

@pavlospt pavlospt changed the title WIP: Allow passing Tokio Handle on ntex-rt Allow passing Tokio Handle on ntex-rt Apr 3, 2024
@fafhrd91
Copy link
Member

fafhrd91 commented Apr 4, 2024

@fafhrd91 fafhrd91 closed this Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants