Skip to content

Commit 1b602dd

Browse files
committed
Simplified Asyncio executor
1 parent f8b3b76 commit 1b602dd

File tree

1 file changed

+1
-15
lines changed

1 file changed

+1
-15
lines changed
Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,6 @@
11
from __future__ import absolute_import
22

33
from asyncio import Future, ensure_future, get_event_loop, iscoroutine, wait
4-
from promise import Promise
5-
6-
7-
def process_future_result(promise):
8-
def handle_future_result(future):
9-
exception = future.exception()
10-
if exception:
11-
promise.reject(exception)
12-
else:
13-
promise.fulfill(future.result())
14-
15-
return handle_future_result
164

175

186
class AsyncioExecutor(object):
@@ -27,9 +15,7 @@ def wait_until_finished(self):
2715
def execute(self, fn, *args, **kwargs):
2816
result = fn(*args, **kwargs)
2917
if isinstance(result, Future) or iscoroutine(result):
30-
promise = Promise()
3118
future = ensure_future(result)
3219
self.futures.append(future)
33-
future.add_done_callback(process_future_result(promise))
34-
return promise
20+
return future
3521
return result

0 commit comments

Comments
 (0)