push_notifications: Fix for aioapns 2.1.

aioapns 2.1 removed the loop parameter from the aioapns.APNs
constructor, because Python 3.10 removed the loop parameter from the
asyncio.Lock constructor.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2022-02-07 23:42:25 -08:00
committed by Tim Abbott
parent 0888a8c628
commit 0ba0620000
2 changed files with 16 additions and 11 deletions

View File

@@ -85,13 +85,16 @@ def get_apns_context() -> Optional[APNsContext]:
# 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,
max_connection_attempts=APNS_MAX_RETRIES,
loop=loop,
use_sandbox=settings.APNS_SANDBOX,
)
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,
)
apns = loop.run_until_complete(make_apns())
return APNsContext(apns=apns, loop=loop)