Skip to content

Concurrent::Promises::Future#value! can return nil even when promise is not resolved yet #1015

Closed
@907th

Description

@907th

Details

* Operating system:                mac
* Ruby implementation:             Ruby
* `concurrent-ruby` version:       1.2.2
* `concurrent-ruby-ext` installed: no
* `concurrent-ruby-edge` used:     no

When main process received SIGINT currently running future.value! returns nil but future.pending? is true and it can be resolved later.

The documentation tells us:

Returns:
(Object, nil, timeout_value) — the value of the Future when fulfilled, or nil on rejection, or timeout_value on timeout.

So I think either the documentation needs to be updated or the signal handling needs to be fixed.

Background

I worked on a code base which used chunks of code like:

task1, task2, ... = Concurrent::Promises.future { ... }, ...
value1, value2, ... = task1.value!, ...
work_with(value1, value2, ...)

It was written in the assumption that nil value means rejection.

I wanted to implement SIGINT handling in the main thread and provide this code with the gracefull shutdown feature. But this code started to report future rejections (false positives) after sending SIGINT to the main process.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA bug in the library or documentation.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions