-
Notifications
You must be signed in to change notification settings - Fork 402
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
Rewrite: APNs from the ground up #100
Conversation
Maybe this time I should go ahead and implement #61 right off the bat |
Here's how the package structure and API is looking:
The namespace means you can use it like this: import pypush.apns no matter how you install it |
Using Can now provide 2 APIs: @pytest.mark.asyncio
async def test_connect():
connection = apns.connection.Connection(certificate, key)
await connection.connect()
assert connection.connected == True
await connection.aclose()
assert connection.connected == False and @pytest.mark.asyncio
async def test_with_block():
async with apns.connection.Connection(certificate, key) as connection:
assert connection.connected == True
assert connection.connected == False I store both the event loop and a list of tasks to cancel inside |
Honestly probably going to stick with recommending ( |
This comment was marked as spam.
This comment was marked as spam.
python3.11 -m venv venv
source ./venv/bin/activate
pip install 'pypush[proxy] @ git+https://github.com/JJTech0130/pypush@initial-rewrite-structure'
sudo apnsproxy |
Just refactored the CLI, the command is now just |
self._tg.start_soon(self._receive_task) | ||
ack = await self.receive(protocol.ConnectAck) | ||
logging.debug(f"Connected with ack: {ack}") | ||
assert ack.status == 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth implementing custom exceptions to differentiate between problems that might occur, and potentially actuate different resilience strategies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My strategy right now has pretty much been "if something goes wrong, catch it with except Exception as e
and try again"... perhaps some proper exceptions can go in the next PR
|
||
|
||
@auto_packet | ||
@dataclass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since every class decorated by auto_packet
is also a dataclass
, can we potentially consolidate the two decorators by applying the dataclass
decorator within the auto_packet
implementation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is actually harder than it sounds, I tried it and it messed up type checking...
…ds for brevity in logs
Trying to get the ball rolling here, this is my proposal for an initial structure of the rewrite.
I've structured it so that APNs will eventually be published as it's own independent PyPI package.
The first stage of
pypush
's rewrite will be to rip everything out, and polish off just APNs by itself.Still need:
asyncio
this time