Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow duck typing for is_future check #1

Merged
merged 1 commit into from
May 28, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions promise.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
try:
from asyncio import Future as AsyncioFuture
except ImportError:
AsyncioFuture = None
try:
from concurrent.futures import Future as ConcurrentFuture
except ImportError:
ConcurrentFuture = None
from threading import Event, RLock


future_classes = tuple(filter(None, (AsyncioFuture, ConcurrentFuture)))


class CountdownLatch(object):

def __init__(self, count):
Expand Down Expand Up @@ -423,7 +412,7 @@ def handle_future_result(future):


def is_future(obj):
return isinstance(obj, future_classes)
return hasattr(obj, "add_done_callback") and callable(getattr(obj, "add_done_callback"))


def is_thenable(obj):
Expand Down