Skip to content

Cancellation semantics for async() and coroutine() #42

@clue

Description

@clue

What should the following code return?

$promise = async(static function (): int {
    try {
        await(React\Promise\Timer\sleep(2));
    } catch (Exception $e) {
        return 1;
    }

    return 2;
})();

$promise->cancel();

var_dump(await($promise));

At the moment, the code would print 1. The same cancellation logic is triggered for fibers (#20) and coroutines (#13). Accordingly, this affects Async v3 and Async v4.

Perhaps we should reject the entire promise? (See also reactphp/promise#56 for discussion about cancellation semantics in Promise v3).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy