3 ms·
A fiber doesn't have a dedicated execution context, so it would be just as blocking.
by byroot 3y ago
A fiber doesn't have a dedicated execution context, so it would be just as blocking.
- Alifatisk 3y agoIs there really no other way than creating a whole thread for this?
- viraptor 3y agoYou can use a pure ruby resolver if you want. For example https://github.com/socketry/async-dns https://github.com/socketry/async-dns But that way your sacrificing integration into your system's nsswitch which may want to do something completely different with your requests. You could also query over dbus which can be async https://www.freedesktop.org/software/systemd/man/latest/org.freedesktop.resolve1.html https://www.freedesktop.org/software/systemd/man/latest/org.... (if you can depend on systemd)
- byroot 3y agoThere is a few alternatives like getaddrinfo_a(3) but they have other downsides (fork safety concerns). If you want more context, you can read: https://bugs.ruby-lang.org/issues/19430 https://bugs.ruby-lang.org/issues/19430