substantic / rain

Framework for large distributed pipelines
https://substantic.github.io/rain/docs/
MIT License
748 stars 54 forks source link

Is support async/await syntax in roadmap or not #74

Open chenray844 opened 6 years ago

chenray844 commented 6 years ago

@all

hi all: I have read the doc on https://substantic.github.io/rain/docs/index.html.

The example given in get-started as below

from rain.client import Client, tasks, blob

# Connect to server
client = Client("localhost", 7210)

# Create a new session
with client.new_session() as session:

    # Create task (and two data objects)
    task = tasks.Concat((blob("Hello "), blob("world!"),))

    # Mark that the output should be kept after submit
    task.output.keep()

    # Submit all crated tasks to server
    session.submit()

    # Wait for completion of task and fetch results and get it as bytes
    result = task.output.fetch().get_bytes()

    # Prints 'Hello world!'
    print(result)

This is so amusing.

But Python3.5+ support async/await syntax, does this project support this syntax?

in roadmap I find this task Update in the Python API (using aiohttp for async API) (@gavento) [medium]. Is it in order to support `async/await1 syntax?

After supporting async/await syntax, the example maybe shows as below

from rain.client import Client, tasks, blob

# Connect to server
client = Client("localhost", 7210)

# Create a new session
async with client.new_session() as session:

    # Create task (and two data objects)
    task = tasks.Concat((blob("Hello "), blob("world!"),))

    # Mark that the output should be kept after submit
    task.output.keep()

    # Submit all crated tasks to server
    session.submit()

    # Wait for completion of task and fetch results and get it as bytes
    result = await task.output.fetch().get_bytes()

    # Prints 'Hello world!'
    print(result)
spirali commented 6 years ago

Hi, I am not sure what exactly @gavento meant by this todo list item. However, we should implement something like your suggestion. So "await" API should go on our list explicitly. We are now both on a vacation, so I will look at it more next week.

On 11 July 2018 11:05:16 CEST, Raymond Chen notifications@github.com wrote:

@all

hi all: I have read the doc on https://substantic.github.io/rain/docs/index.html.

The example given in get-started as below

from rain.client import Client, tasks, blob

# Connect to server
client = Client("localhost", 7210)

# Create a new session
with client.new_session() as session:

   # Create task (and two data objects)
   task = tasks.Concat((blob("Hello "), blob("world!"),))

   # Mark that the output should be kept after submit
   task.output.keep()

   # Submit all crated tasks to server
   session.submit()

   # Wait for completion of task and fetch results and get it as bytes
   result = task.output.fetch().get_bytes()

   # Prints 'Hello world!'
   print(result)

This is so amusing.

But Python3.5+ support async/await syntax, does this project support this syntax?

in roadmap I find this task Update in the Python API (using aiohttp for async API) (@gavento) [medium]. Is it in order to support `async/await1 syntax?

After supporting async/await syntax, the example maybe shows as below

from rain.client import Client, tasks, blob

# Connect to server
client = Client("localhost", 7210)

# Create a new session
async with client.new_session() as session:

   # Create task (and two data objects)
   task = tasks.Concat((blob("Hello "), blob("world!"),))

   # Mark that the output should be kept after submit
   task.output.keep()

   # Submit all crated tasks to server
   session.submit()

   # Wait for completion of task and fetch results and get it as bytes
   result = await task.output.fetch().get_bytes()

   # Prints 'Hello world!'
   print(result)

-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/substantic/rain/issues/74

-- Sent from my Android device with K-9 Mail. Please excuse my brevity.

spirali commented 6 years ago

I have made a quick look on Python3 futures and I do not see how to simply combine futures and capnp promises (however it may still need only few lines of code, but I do not see deep into both). So if someone did not make combination of futures and promises, it has to wait until we did not finish removing of capnp from the client. Nevertheless, async/await API should be definitely part of our API.