Questions tagged [fibers]

A fiber is a lightweight thread which uses cooperative rather than preemptive multitasking. It is very similar to and often confused with a [coroutine]. Use this tag for questions relating to the [ruby] feature, otherwise prefer to use [coroutine].

A fiber is a lightweight thread which uses cooperative rather than preemptive multitasking. It is very similar to and often confused with a .

In Ruby, fibers are primitives for implementing light weight cooperative concurrency. It appeared in Ruby 1.9.

Related tags

189 questions
2
votes
1 answer

Best way to deal with sleeping in event handlers in a single-threaded API?

I'm using a non-threadsafe event API. wait() is called, and from that call, event handlers are dispatched. I want to be able to, within an event handler, "sleep" for some time. Currently, I have a scheduler that schedules functions to be called at a…
Sgeo
  • 85
  • 8
2
votes
1 answer

Fibers and multiple http requests in Sinatra

I have problems understanding what is happening when calling external APIs using the fibers model with eventmachine. I have this code in Sinatra: get '/' do conn = Faraday.new 'http://slow-api-call' do |con| con.adapter :em_http end resp =…
Ron
  • 2,215
  • 3
  • 22
  • 30
2
votes
1 answer

Sinatra + Fibers + EventMachine

I would like to know to to pause a Root Fiber in ruby (if possible). I have this Sinatra app, and I am making async calls to an external API with EventMachine. I don't want to respond to the client until the api responds me. For example, sleeping…
Ron
  • 2,215
  • 3
  • 22
  • 30
2
votes
1 answer

Strange behavior with Thread and Fiber

This code: Fiber.new do Thread.current['a'] = 5 p Thread.current.object_id p Thread.current['a'] Fiber.new do p Thread.current.object_id p Thread.current['a'] end.resume p Thread.current.object_id p…
the-teacher
  • 589
  • 8
  • 19
2
votes
2 answers

Meteor isn't working on Windows7 64 bit

I am just trying out Meteor on my Windows 7 enterprise 64 bit box. I installed it via MSI from http://win.meteor.com, rebooted the machine and in command prompt (administrator), did the following: cd /d c:\var meteor create testapp (absolutely…
Varun K
  • 3,593
  • 2
  • 25
  • 26
2
votes
1 answer

Ruby: Get Fiber parent

Is it possible to retrieve the fiber which created the current fiber? It would suffice if I could get this information upon creation of a new Fiber. Monkey-patching Fiber#new doesn't work, as calling Fiber#current results in "uninitialized fiber"…
mikabytes
  • 1,818
  • 2
  • 18
  • 30
2
votes
0 answers

How to use Rack::FiberPool and EventMachine for JRuby/Rails app on Tomcat?

I have a JRuby/Rails app using Rack::FiberPool and EventMachine. And I have some event-based action controller: class TwitterController < ApllicationController def tweets fiber = Fiber.current tweets = nil EventMachine.next_tick do …
Blue Smith
  • 8,580
  • 2
  • 28
  • 33
2
votes
2 answers

Ruby 1.9.3-p140 - Using Thread - how to wait for all results to come out from threads?

I'm trying to figure out a good way to wait for all threads to be executed before the main thread finishes. How can I do that in the following code? threads = [] counter = 1000 lines = 0 counter.times do |i| puts "This is…
Thanks for all the fish
  • 1,671
  • 3
  • 17
  • 31
1
vote
1 answer

Em-synchrony sample code not working as expected

The em-synchrony documentation links to this article which implies that this code with fiber: require 'eventmachine' require 'fiber' require 'em-http-request' def http_get(url) f = Fiber.current http = EventMachine::HttpRequest.new(url).get …
iftheshoefritz
  • 5,829
  • 2
  • 34
  • 41
1
vote
0 answers

Wrong data stored in SFP module EEPROM?

I want to distinguish several 1G SFP modules are copper or fiber. So I read the data from the EEPROM with ethtool. And I think the 'connector type' would be the most crucial info for me to achieve the goal. Three fiber ones' connector type are all…
Jack
  • 11
  • 1
1
vote
1 answer

join on cats-effect fiber doesn't raise inner error

A cats-effect fiber, once started, a reference kept of it, some other code executed and then rejoined, won't raise the errors that happen inside. Do you know why .join doesn't throw an error and why my application doesn't quit. Why will a thread…
Hunor Kovács
  • 1,062
  • 9
  • 16
1
vote
1 answer

PHP Fibers return null values

While running below code, it return empty values. I have used fibers to run the code and used PHP version is 8.2
Rasid
  • 23
  • 3
1
vote
0 answers

node-gyp "Error: `make` failed with exit code" when npm install on a m2 pro

I just purchased a MacBook M2 Pro and am trying to run an old Vue project of mine with node v19.6.0 and npm 6.14.18. While doing an npm install, I'm getting 2 errors which seems to be related to node-gyp building with some other packages like…
ege
  • 812
  • 6
  • 16
1
vote
0 answers

Userspace thread a-ka fiber fails to `printfn` when some pattern like `%i` or other is being used

I am playing with my own fibers; more for educational sake. My platform is x86-64 & Linux. Here is my context-switching routine __taskflow_switch_cpu_context: // preserve the $rbp, plays together with the `-fno-omit-frame-pointer` …
Zazaeil
  • 3,900
  • 2
  • 14
  • 31
1
vote
1 answer

golang Fiber no getting user register ID

I am learning fiber framework and JWT Auth. The register Func and Login Func correctly saves the user Id in the database. The cookie and JWT are are retrieved correctly and displayed the cookie and persisted on the front end. When I attempt to get…
Gerardo
  • 19
  • 2