Don’t import typing.Deque at runtime (for Python < 3.5.4)

On Ubuntu 16.04, which has Python 3.5.2, `apns2.client` failed to
import, because `typing.Deque` was not added until Python 3.5.4.

Fixes #88.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This commit is contained in:
Anders Kaseorg
2019-10-08 22:49:46 +03:00
committed by Sergey Petrov
parent 2f02f0f479
commit 88ee900854
+3 -2
View File
@@ -2,11 +2,12 @@ import collections
import json
import logging
import time
import typing
import weakref
from enum import Enum
from json import JSONEncoder
from threading import Thread
from typing import Deque, Dict, Iterable, Optional, Tuple, Type, Union
from typing import Dict, Iterable, Optional, Tuple, Type, Union
from .credentials import CertificateCredentials, Credentials
from .errors import ConnectionFailed, exception_class_for_reason
@@ -185,7 +186,7 @@ class APNsClient(object):
self.connect()
results = {}
open_streams = collections.deque() # type: Deque[RequestStream]
open_streams = collections.deque() # type: typing.Deque[RequestStream]
# Loop on the tokens, sending as many requests as possible concurrently to APNs.
# When reaching the maximum concurrent streams limit, wait for a response before sending
# another request.