Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spin group wait causes ClosedQueueError #575

Open
cFire opened this issue Dec 15, 2024 · 0 comments
Open

Spin group wait causes ClosedQueueError #575

cFire opened this issue Dec 15, 2024 · 0 comments

Comments

@cFire
Copy link
Contributor

cFire commented Dec 15, 2024

After updating to 2.2.3 to 2.3.0, waiting in a spingroup seems to have broken and now throws a ClosedQueueError.

Minimal test case:

require 'cli/ui'

CLI::UI::StdoutRouter.enable

CLI::UI::SpinGroup.new do |sg|
  # Task 1
  sg.add('pending') { |spinner|
    result = { 'message' => 'mock api result' }
    sleep(0.5)
    spinner.update_title(result['message'])
  }

  # Wait for previous task to finish before starting the next
  sg.wait

  # Task 2
  sg.add('pending 2') { |spinner|
    result = { 'message' => 'mock api result 2' }
    sleep(0.5)
    spinner.update_title(result['message'])
  }
end

Full output:

# ruby test.rb
✓ mock api result
/usr/local/bundle/gems/cli-ui-2.3.0/lib/cli/ui/work_queue.rb:86:in `push': queue closed (ClosedQueueError)
        from /usr/local/bundle/gems/cli-ui-2.3.0/lib/cli/ui/work_queue.rb:86:in `enqueue'
        from /usr/local/bundle/gems/cli-ui-2.3.0/lib/cli/ui/spinner/spin_group.rb:135:in `initialize'
        from /usr/local/bundle/gems/cli-ui-2.3.0/lib/cli/ui/spinner/spin_group.rb:315:in `new'
        from /usr/local/bundle/gems/cli-ui-2.3.0/lib/cli/ui/spinner/spin_group.rb:315:in `block in add'
        from /usr/local/bundle/gems/cli-ui-2.3.0/lib/cli/ui/spinner/spin_group.rb:314:in `synchronize'
        from /usr/local/bundle/gems/cli-ui-2.3.0/lib/cli/ui/spinner/spin_group.rb:314:in `add'
        from test.rb:17:in `block in <main>'
        from /usr/local/bundle/gems/cli-ui-2.3.0/lib/cli/ui/spinner/spin_group.rb:93:in `initialize'
        from test.rb:5:in `new'
        from test.rb:5:in `<main>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant