Skip to content

Implement on top of concurrent.futures #8

Open

Description

@wmertens

I have tried to use aplus, but I couldn't make it run the error handler when an exception occurred such as a typo in the called code.

I then switched to concurrent.futures (the backported one) and that works fine for exceptions, but I miss the Promises/A+ interface, especially being able to transparently return a new promise as the result of a promise.

Activity

  1. xogeny commented on Jun 10, 2014

    @xogeny
    Owner

    Could you be a bit more specific about what you'd like aplus to do? A test case would be great. I suspect it can be done (and still satisfy the A+ spec).

  2. xogeny commented on Jun 10, 2014

    @xogeny
    Owner

    And implementing on top of concurrent.futures is probably a good idea. I just don't know much about it. The problem is that Python doesn't really lend itself so well to this kind of thing without a standard way of dealing with queueing of work to be done.

  3. wmertens commented on Jun 10, 2014

    @wmertens
    Author

    Well, I tried to use aplus.background(lambda: somefunction(foo)).then(...) in various ways, but code errors did not throw exceptions.

    When instead I did

       import futures
       executor = futures.ThreadPoolExecutor(max_workers=100)
        f = executor.submit(somefunction, foo)
    
        def cb(f):
            if f.exception() is not None:
                log.warn("FAIL: {}".format(f.exception()))
            else:
                log.info("Success: {}".format(f.result()))
        f.add_done_callback(cb)
    

    Much uglier than Promises/A+, but it works...

  4. xogeny commented on Jun 11, 2014

    @xogeny
    Owner

    Thanks for your feedback. I don't expect to have time in the near term to look into this. But I'll keep this open. Perhaps someone else will come along and implement something here. I'd gladly accept a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions