ufo-kit/concert — pull request #265 by matze (2014-06-07 11:13:59+00:00)
Title: Proposal: asynchronous execution of scans

After yesterday's discussion, I thought how we could run our scans asynchronously *and* receive each value on the fly. We have all the tools available and the most straightforward way is to generate *futures* instead of using one future to wrap the scan. With the attached proposal you can do the following:

```python
fs = [f for f in scan(motor['position'], lambda: None)] # returns immediately

for f in fs:
x, y = f.result() # blocks if not yet ready
```

For a scan GUI I could imagine the following snippet:

```python
for future in scan(motor['position'], lambda: None)):
def plot(f):
x, y = f.result()
# add x, y to the plot

future.add_done_callback(plot)
```
which already works fine in the shell.

Now we have a bit more logic inside the scan and frankly I don't know how we could generalize that for making it useful for other processes. So, @tomago: any comments?