58
58
59
59
NoneType = type (None )
60
60
61
+ # In Python 3.4.4, `async` was renamed to `ensure_future`.
62
+ try :
63
+ ensure_future = asyncio .ensure_future
64
+ except AttributeError :
65
+ ensure_future = asyncio .async
66
+
61
67
62
68
class ZScoreBoundary :
63
69
"""
@@ -634,7 +640,7 @@ def done(result):
634
640
typecheck_return (protocol_self , result )
635
641
future2 .set_result (result )
636
642
637
- future .add_done_callback (lambda f : asyncio . ensure_future (done (f .result ()), loop = protocol_self ._loop ))
643
+ future .add_done_callback (lambda f : ensure_future (done (f .result ()), loop = protocol_self ._loop ))
638
644
639
645
return future2
640
646
@@ -806,7 +812,7 @@ def connection_made(self, transport):
806
812
# Start parsing reader stream.
807
813
self ._reader = StreamReader (loop = self ._loop )
808
814
self ._reader .set_transport (transport )
809
- self ._reader_f = asyncio . ensure_future (self ._reader_coroutine (), loop = self ._loop )
815
+ self ._reader_f = ensure_future (self ._reader_coroutine (), loop = self ._loop )
810
816
811
817
@asyncio .coroutine
812
818
def initialize ():
@@ -825,7 +831,7 @@ def initialize():
825
831
if self ._pubsub_patterns :
826
832
yield from self ._psubscribe (self ._subscription , list (self ._pubsub_patterns ))
827
833
828
- asyncio . ensure_future (initialize (), loop = self ._loop )
834
+ ensure_future (initialize (), loop = self ._loop )
829
835
830
836
def data_received (self , data ):
831
837
""" Process data received from Redis server. """
@@ -980,7 +986,7 @@ def _handle_multi_bulk_reply(self, cb):
980
986
981
987
# Return the empty queue immediately as an answer.
982
988
if self ._in_pubsub :
983
- asyncio . ensure_future (self ._handle_pubsub_multibulk_reply (reply ), loop = self ._loop )
989
+ ensure_future (self ._handle_pubsub_multibulk_reply (reply ), loop = self ._loop )
984
990
else :
985
991
cb (reply )
986
992
0 commit comments