GithubHelp home page GithubHelp logo

Comments (6)

johnae avatar johnae commented on July 21, 2024

So basically, removing the "Blah" class above and letting Client and Server inherit directly from ZMQEntity works on both 0.13.0 and 0.14.0, unfortunately that's not a reasonable "fix" on the much larger project where I encountered this issue.

from celluloid-zmq.

halorgium avatar halorgium commented on July 21, 2024

I would imagine this to be a problem with the determination of the mailbox class.
Can you confirm if this is problem with IO too?
If so, it is should be a core fix.

from celluloid-zmq.

johnae avatar johnae commented on July 21, 2024

Well I did a simple test on IO and that wouldn't work on either 0.13.0 or 0.14.0 - basically just hung there. Just by introducing an intermediate class before the actual final implementations. Perhaps I did something wrong there but here's the code for IO that I tried:

if ENV.key?('CELLULOID_14')
  gem 'celluloid-io', '=0.14.0'
  gem 'celluloid', '=0.14.0'
else
  gem 'celluloid-io', '=0.13.0'
  gem 'celluloid', '=0.13.0'
end

require 'celluloid/io'

class IOEntity

  include Celluloid::IO

  def initialize(host, port)
    @host = host
    @port = port
  end

end

class Blah < IOEntity
  def initialize(host,port)
    super
  end
end

class EchoClient < Blah

  def initialize(host, port)
    super
    every(2) do
      echo "Hello from client: #{Time.now}"
    end
  end

  def socket
    @socket ||= TCPSocket.new(@host, @port)
  end

  def echo(s)
    socket.write(s)
    puts socket.readpartial(4096)
  end

end

class EchoServer < Blah

  finalizer :finalize

  def initialize(host, port)
    super
    puts "*** Starting echo server on #{host}:#{port}"

    # Since we included Celluloid::IO, we're actually making a
    # Celluloid::IO::TCPServer here
    @server = TCPServer.new(@host, @port)
    async.run
  end

  def finalize
    @server.close if @server
  end

  def run
    loop { async.handle_connection @server.accept }
  end

  def handle_connection(socket)
    _, port, host = socket.peeraddr
    puts "*** Received connection from #{host}:#{port}"
    loop { socket.write socket.readpartial(4096) }
  rescue EOFError
    puts "*** #{host}:#{port} disconnected"
    socket.close
  end
end

supervisor = EchoServer.supervise("127.0.0.1", 1234)
trap("INT") { supervisor.terminate; exit }
client = EchoClient.new("127.0.0.1", 1234)
puts client.echo("Initial hello from client: #{Time.now}")
sleep

from celluloid-zmq.

johnae avatar johnae commented on July 21, 2024

No, I made a mistake. Had to also specify the Celluloid gem version. I edited above example code for Celluloid-IO and now it fails in the same way ZMQ does, eg. works on 0.13.0, fails on 0.14.0. Sounds reasonable that it has to do with the mailbox class determination.

from celluloid-zmq.

johnae avatar johnae commented on July 21, 2024

@halorgium Yes, it seems to be the determination of the mailbox class. Here's some output when checking what kind of class that is:

Inheriting directly from toplevel class:

[ john ~ ]$ CELLULOID_14=yes ruby celluloid_io_test.rb 
0.14.0
*** Starting echo server on 127.0.0.1:1234
Celluloid::IO::Mailbox ## it's the "correct" celluloid evented mailbox as it should be
*** Received connection from 127.0.0.1:53928
Initial hello from client: 2013-05-13 17:57:44 +0200

Inheriting from a subclass of the toplevel class:

[ john ~ ]$ CELLULOID_14=yes ruby celluloid_io_test.rb 
0.14.0
*** Starting echo server on 127.0.0.1:1234
Celluloid::Mailbox ## it's the "standard" celluloid mailbox when it shouldn't be

Didn't test on ZMQ but I assume the same thing happens. It's probably somewhere around here:

https://github.com/celluloid/celluloid/blob/v0.14.0/lib/celluloid.rb#L288

I'll be filing the issue with a link to here directly in the main Celluloid repo now.

from celluloid-zmq.

halorgium avatar halorgium commented on July 21, 2024

Closing in favor of celluloid issue.

from celluloid-zmq.

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.