Giter Club home page Giter Club logo

Comments (6)

alloy avatar alloy commented on July 30, 2024 1

Ace! Thanks for the feedback ๐Ÿ‘

from lowdown.

alloy avatar alloy commented on July 30, 2024

Hey, great to hear it works well for you in general!

Regarding your delayed issue, its a bit tough for me to judge just by this info what might be going on, I would need more info to be able to better help you diagnose the problem. I can tell you, however, that we are also using it from a DJ queue, the main thing there is that I do not call delay on a Client instance, but rather on a class method of our internal PushNotificationService class which forwards that delayed call to the processโ€™ Client singleton instance.

from lowdown.

swelther avatar swelther commented on July 30, 2024

Thanks for your answer, alloy :) Good to see that someone managed to use it from a DJ queue.

I have a distinct class like this:

class SendPendingMessagesJob < ActiveJob::Base
  queue_as :default

  def perform(message)
  end
end

And in the perform method the Client instance is created by calling production and during that the whole job hangs until forever ๐Ÿ˜ž

BTW: Without the initializer method the results are the same :(

from lowdown.

alloy avatar alloy commented on July 30, 2024

Hmm, Iโ€™m thinking that maybe this is happening because youโ€™re requiring the sources very early and thatโ€™s triggering Celluloid to load and not work anymore after forking.

Could it be that you are e.g. letting Bundler load the Lowdown sources when your Rails app starts?

I have this in our Gemfile:

gem 'lowdown', require: false

And my internal client class actually differs slightly from the README example, in that it just-in-time requires Lowdown:

class PushNotificationService
  def initialize(certificate_path)
    @certificate_path = certificate_path
    @client_mutex = Mutex.new
  end

  def client
    client = nil
    @client_mutex.synchronize do
      require 'lowdown' # <-- just-in-time loading of Lowdown
      @client ||= Lowdown::Client.production(true, File.read(certificate_path), keep_alive: true)
      client = @client
    end
    client
  end
end

This all makes sure that Lowdown, and in turn Celluloid, do not get loaded until they are actually needed.

Please let me know if this fixes it, in which case I will amend the README and also have another think about how to possibly make this simpler to use.

from lowdown.

swelther avatar swelther commented on July 30, 2024

Yes, that was exactly the point! Now it works. Thank you very much. ๐Ÿ˜„

Adding that to the readme would be an awesome idea.

from lowdown.

joemasilotti avatar joemasilotti commented on July 30, 2024

Thanks for showing off your implementation, @alloy. I ran into exactly this same issue and "lazy requiring" lowdown was the fix. +1 for adding this to the README and/or a slightly modified approach.

from lowdown.

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.