Is Typhoeus thread-safe?

369 views Asked by At

This is the exact way I'm using it. I'm having difficulty finding a clear answer after a very lot of Googling.

If used in the following simple manner:

class CancelSubscriptionWorker
  include Sidekiq::Worker

  sidekiq_options retry: 3

  def perform(body)
    resp = Typhoeus::Request.new("http://example.com", {
      method: :post,
      timeout: 27,
      body: body.to_json,
      userpwd: 'aaa:bbb',
      headers: {
        'Content-Type': 'application/json'
      }
    }).run
  end
end

and i'm doing this inside a Sidekiq worker, is this thread-safe?

I am not using Hydra, and I don't care about keep-alive or connection pools. I'm also not sharing any variables across threads. The code above appears in a simple Sidekiq worker, and that worker is run many times per second.

1

There are 1 answers

0
diderevyagin On

Early versions had problems with the race, please attention to this discussion: https://github.com/typhoeus/typhoeus/issues/301

but now everything should work thread safe