Closed Geobert closed 4 years ago
Huh, it was never intended to be used in this way. I suppose that with 0.6 it "worked" because tokio-core
requires an explicit runtime handle for all operations. If the library had ever been ported to tokio-0.1
, you'd have the same problem there.
So yes, switch to async throughout.
It ended that I can't use async version, because it's in an trait impl from oxide-auth
and it's sync. I'll use spawn_blocking
to use sync version of ldap3. A pity, but it will work :)
EDIT: more details https://users.rust-lang.org/t/calling-async-while-implementing-sync-trait/43388
It should be possible to a) spin up an OS thread with its own Tokio runtime and one or more LDAP connections, b) make a synchronous bridge that will block in other threads and forward requests to the LDAP runtime. I don't yet see it as something that would be included in ldap3
proper, it's a bit specialized.
Do you have a repo/gist which could reproduce your problem config?
Unfortunately it's closed source, but I can craft an example to demonstrate my issue yes:
I have a workaround for now (see the Rust forum thread above), but I think the simpler would be waiting for async oxide-auth (which is WIP)
Ah, from the URLO thread and the code I finally saw what you meant to do. The solution, spawn_blocking()
, is not a workaround, but an architectural necessity: you don't want to call blocking operations directly in an async context, and the inverse doesn't work without a runtime. Of course, once every support library is async, you can use it exclusively.
Hi,
I migrated an internal project to 0.7 and being hit by this error:
I'm using synchronous API but I can see the the synchronous implementation just
block_on
async code.I don't know if this is intended and I'll switch to Async API but I wanted to signal this as a difference from 0.6 branch :)
Regards,