-
Notifications
You must be signed in to change notification settings - Fork 18
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
Add default FiberScheduler to rage console #125
base: master
Are you sure you want to change the base?
Add default FiberScheduler to rage console #125
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @TheBlackArroVV , thank you for the PR! This is pretty much what we are looking for, but it doesn't work correctly in all cases.
It works fine with synchronous fibers (e.g. Fiber.schedule { rand }
) but doesn't work correctly with asynchronous.
For example, running the following code in the console raises attempt to yield on a not resumed fiber (FiberError)
:
require "net/http"
Fiber.await(Fiber.schedule { Net::HTTP.get(URI("http://httpbin.org/delay/1")) })
The reason for that is that Rage::FiberScheduler
is using the server's reactor - if the server is not running, the scheduler will not work. Thus, we will likely need a mock scheduler here, similar to the one we use in tests.
Hey, @rsamoilov, |
Array(fibers).map(&:__get_result) | ||
end | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, this is the same as requiring the file 😞
This patch also applies to the server process, effectively making all code inside the application synchronous.
You can verify this by creating a new Rage app and adding an action that calls sleep 1
. Sending however many requests in parallel to this action should only take one second, but with these changes Rage will be processing the requests one by one.
Instead, we only want these changes applied to the console method.
Closes #115