Skip to content

memoizing across Fibers? (heavy graphql-ruby usage) #885

Closed Answered by jakswa
jakswa asked this question in Q&A
Discussion options

You must be logged in to vote

Ah, here is what I was missing: graphql-ruby has implemented a bridge across this gap, and copies Thread locals to Fibers upon creation:

    def spawn_fiber
      fiber_vars = get_fiber_variables
      Fiber.new(blocking: !@nonblocking) {
        set_fiber_variables(fiber_vars)

taken from https://github.com/rmosolgo/graphql-ruby/blob/5dcdb597c4dd9dc943b8a86f11c271a32d2a97a4/lib/graphql/dataloader.rb#L65-L77

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by jakswa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant