ruby-concurrency / ruby-concurrency/concurrent-ruby

Actor pool terminated event sent as message

Abierto
#813 0 comentarios 0 reacciones 1 asignado Ver en GitHub

@pitr-ch ya está trabajando en esto.

Desde el 24/8/2019.

question
Lenguaje dominante
Ruby
Estrellas
5.8k
Forks
420
Merge medio
20 h 45 min
PR fusionados (30 d)
4

Descripción

  • Operating system: Linux
  • Ruby implementation: Ruby
  • concurrent-ruby version: 1.1.5
  • concurrent-ruby-edge version: 0.5.0

Given this code:

require 'concurrent-edge'

class WorkerActor < Concurrent::Actor::RestartingContext
  def on_event(event)
    puts "#{name} event: #{event.inspect}"
  end
end

class Actor < Concurrent::Actor::RestartingContext
  def initialize
    @worker_pool = Concurrent::Actor::Utils::Pool.spawn('worker_pool', 10) do |index|
      WorkerActor.spawn(name: "worker[#{index}]", supervise: true)
    end
  end

  def on_message(message)
    puts "#{name} message: #{message.inspect}"
  end

  def on_event(event)
    puts "#{name} event: #{event.inspect}"
  end
end

actor = Actor.spawn(name: 'parent')

actor << :terminate!

sleep 0.1

-why does the Actor receive both an event :terminated and a message :terminated? Output from the above:

parent event: [:terminated, nil]
worker[0] event: [:terminated, nil]
worker[1] event: [:terminated, nil]
worker[2] event: [:terminated, nil]
worker[3] event: [:terminated, nil]
worker[4] event: [:terminated, nil]
worker[5] event: [:terminated, nil]
worker[6] event: [:terminated, nil]
worker[7] event: [:terminated, nil]
worker[8] event: [:terminated, nil]
worker[9] event: [:terminated, nil]
parent message: [:terminated, nil]

It only seems to receive a message when I use a Pool. If I replace the #initialize method with:

@worker = WorkerActor.spawn(name: 'worker', supervise: true)

Then the output includes only events and no message:

parent event: [:terminated, nil]
worker event: [:terminated, nil]

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.