-
Notifications
You must be signed in to change notification settings - Fork 3
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
Question about io_read #1
Comments
Hey, the https://docs.ruby-lang.org/en/3.1/Fiber/SchedulerInterface.html#method-i-io_read |
So, reading over that again, the issue I see is that if one calls In practise, copying this code into my fiber scheduler I see the above happen when running the specs, which causes them to fail. |
Yea, this is interesting. So, the selector from this gem was taken from Samuel's The socketry/io-event@f173fad#diff-a12eb715e8d43c5484492317b228fc02363668ad6c4ac27e7a3e0f94cb26da18 |
It's obviously a special case for something, I'm not sure what. We should ask Samuel - can I ask him to add you to socketry slack? |
Sure, you can find my email for such invites, etc at https://singpolyma.net/ |
Hey @bruno- ! Just checked that, with the basic example: require "fiber_scheduler"
require "open-uri"
FiberScheduler do
Fiber.schedule do
URI.open("https://httpbin.org/delay/2")
end
Fiber.schedule do
URI.open("https://httpbin.org/delay/2")
end
end Running with 3.1.0, it works ok, but with 3.2.0:
Seems something changed with 3.2.0. |
+1 @taq Here it works if you add (:waiting) to the block. 🤷🏻♂️ require "fiber_scheduler"
require "open-uri"
FiberScheduler do
Fiber.schedule(:waiting) do
URI.open("https://httpbin.org/delay/2")
end
end |
Nice @aristotelesbr ! Will try here and take a look why on 3.2 it is needed. |
Can someone please elaborate on what And while it does run with this change, it does not "run" The fibers are not firing anymore. Is there a corollary command to run later, which should start the fibers that are waiting? (I'm rolling back to Ruby 3.1.3 for now, to get the fibers running again) I'm sure I can find more information about this myself searching, but it's the third time I've had to come back to this thread so I thought it might actually be helpful to ask for clarification at this point! edit: Code |
Hey @kingdonb I still didn't have time to take a look at this, but seems some method calls changed on 3.2. I noticed it prior to give a Ruby online class where I showed Fibers. |
Hey @bruno- I checked where the error is, and it's here on def io_read(io, buffer, length)
@selector.io_read(Fiber.current, io, buffer, length)
end but the current code here on Github on the same file is def io_read(fiber, io, buffer, length, offset = 0) which handle the offset as the last parameter, making it work with Ruby 3.2.0 as the commit here provides: 316d5aa So, seems we just need a new gem release. :-) |
@bruno- if you need some help, just let me know. |
I have a question about the logic in
io_read
at https://github.com/bruno-/fiber_scheduler/blob/main/lib/fiber_scheduler/selector.rb#L98It seems that it considers the resource unavailable (
-EAGAIN
) iflength == 0
and the read failed. This makes sense because if I try to read nothing and it fails, then it must not be possible to read. However the read does not uselength
at all! It usesmaximum_size
which looks likely to be related tolength
, but is not the same value. Should this perhaps instead saysif maximum_size > 0
?The text was updated successfully, but these errors were encountered: