async def make_apns() -> aioapns.APNs: return aioapns.APNs( client_cert=settings.APNS_CERT_FILE, topic=settings.APNS_TOPIC, max_connection_attempts=APNS_MAX_RETRIES, use_sandbox=settings.APNS_SANDBOX, )
def get_apns_context() -> Optional[APNsContext]: # We lazily do this import as part of optimizing Zulip's base # import time. import aioapns if settings.APNS_CERT_FILE is None: return None # NB if called concurrently, this will make excess connections. # That's a little sloppy, but harmless unless a server gets # hammered with a ton of these all at once after startup. loop = asyncio.new_event_loop() apns = aioapns.APNs( client_cert=settings.APNS_CERT_FILE, topic=settings.APNS_TOPIC, loop=loop, use_sandbox=settings.APNS_SANDBOX, ) return APNsContext(apns=apns, loop=loop)
def get_apns_context() -> Optional[APNsContext]: # We lazily do this import as part of optimizing Zulip's base # import time. import aioapns # aioapns logs at "error" level for every non-successful request, # which fills the logs; see https://github.com/Fatal1ty/aioapns/issues/15 logging.getLogger("aioapns").setLevel(logging.CRITICAL) if settings.APNS_CERT_FILE is None: return None # NB if called concurrently, this will make excess connections. # That's a little sloppy, but harmless unless a server gets # hammered with a ton of these all at once after startup. loop = asyncio.new_event_loop() apns = aioapns.APNs( client_cert=settings.APNS_CERT_FILE, topic=settings.APNS_TOPIC, loop=loop, use_sandbox=settings.APNS_SANDBOX, ) return APNsContext(apns=apns, loop=loop)