Code Monkey home page Code Monkey logo

Comments (7)

andreas avatar andreas commented on June 22, 2024

Can you provide a backtrace please?

from podio-rb.

danmaz74 avatar danmaz74 commented on June 22, 2024

Hi Andreas

We found the reason of the problem, and why it worked in testing but not in production. We are doing the API setup in a initializers/podio.rb file, with

Podio.setup(:api_key => 'YOUR_API_KEY', :api_secret => 'YOUR_API_SECRET')
Podio.client.authenticate_with_credentials('YOUR_PODIO_ACCOUNT', 'YOUR_PODIO_PASSWORD')

Now, the problem is that in production we use Passenger (with Apache), and we discovered that the setup is only done once when starting the server - not once for every process that Passenger spawns. And your client is somehow tied to the process itself, so, inside each passenger processes, Podio.client is actually nil

We did a quick fix by adding a before_filter to ApplicationController, and init the api if Podio.client.nil? , but this is very ugly. If you are aware of - or can find - any better solution to init the API only once, in a way that works with Passenger (which I think is used by 99% of Rails developers), that would be very useful :)

from podio-rb.

andreas avatar andreas commented on June 22, 2024

The gem uses thread local storage to store the current connection, which I think is causing what you're experiencing. This is mentioned briefly in the readme, but should probably be more explicit. We'll try think of a better solution -- thanks for bringing up the issue!

from podio-rb.

danmaz74 avatar danmaz74 commented on June 22, 2024

Ok, please update us if you find one!

from podio-rb.

jclay avatar jclay commented on June 22, 2024

Just ran into this issue as well. Thanks for the workaround @danmaz74

from podio-rb.

f6v avatar f6v commented on June 22, 2024

Having the same issue when calling Podio in Sidekiq job. What's the best way to initialise library when using Sidekiq?

from podio-rb.

cpeters avatar cpeters commented on June 22, 2024

I haven't personally used Sidekiq but I did a quick scan of the docs. There is a mention that workers must be thread safe. It appears that you'd have to initialize a connection to the Podio Api within each worker.

from podio-rb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.