Skip to content

future state is "running" after it has been resolved #193

Closed
@keithing

Description

@keithing

On my machine (Ubuntu 14.04) it's possible for a future to be resolved yet have a state of "running". I'm not sure if this is intentional or not, since it seems possible to know whether a future is "finished" or "failed" before value is called, but maybe that's not the future design philosophy.

Here's a reproducible example:

library(future)                                                                 
                                                                                
# Run futures in a different process                                            
plan("multiprocess", workers=2)                                                 
                                                                                
# Create a future to sleep for 4 seconds                                        
fut <- future({                                                                 
  Sys.sleep(4)                                                                  
  2 + 2                                                                         
})                                                                              
                                                                                
# Test that I can do stuff while I'm waiting for future                         
print("Parallel!")                                                              
                                                                                
# Wait for future to be resolved                                                
while (!resolved(fut)) {                                                        
  Sys.sleep(1)                                                                  
}                                                                               
                                                                                
# This should be in a completed state like "finished" or "failed"               
print(fut$state)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions