-
Couldn't load subscription status.
- Fork 74
Initial Asyncio Module PR [1/3] #741
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
base: master
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #741 +/- ##
==========================================
- Coverage 95.33% 93.41% -1.93%
==========================================
Files 378 389 +11
Lines 21992 24426 +2434
==========================================
+ Hits 20967 22818 +1851
- Misses 1025 1608 +583 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
I've added the diff between modules in this PR vs their counterparts in the old API to the PR description. |
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.
Had a quick look.
For others: probably easier to use https://difftastic.wilfred.me.uk/introduction.html to make life easier.
Haven't studied the reactor in-detail and associated logic in detail. From the diff it looked like the changes were relatively minor, albeit many of them.
I can review those in-depth if needed (or you cannot find people).
hazelcast/asyncio/client.py
Outdated
| _CLIENT_ID = AtomicInteger() | ||
|
|
||
| @classmethod | ||
| async def create_and_start(cls, config: Config = None, **kwargs) -> "HazelcastClient": |
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.
General note -- I'm sure there are others.
If we're trying to get this API nice w.r.t. typing as well then this will probably show some error by default as None is not applicable for Config. Might be more prominent here as I think this is entry point into client creation.
Same for __init__ -- config: Config | None.
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 missing something in the diff: in client.py there's a load of documentation -- is it elsewhere, or why omit it for this one? (most likely doc applicable from __init__)
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.
re: Docs, I mentioned that in the PR description:
I didn't include the API docs, in order to make the PR smaller. I'll add them in another PR.
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.
If you use better diff tool it doesn't make a difference. Give that one I mentioned a go.
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.
I can review those in-depth if needed (or you cannot find people).
Yes, please.
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.
At least with PyCharm, the user gets the correct type annotation.
There is this project in case you'd like to try the asyncio module:
https://github.com/yuce/hazelcast-asyncio-sample
In any case, I pushed a PR that adds explicit |None:
baa3bc1
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.
PyCharm may be more forgiving -- I've never used it. pyright or pyrefly are good tools to use to determine compliance to the type invariants specified using type annotations.
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.
We check the typings with mypy.
| raise | ||
| _logger.info("Client started") | ||
|
|
||
| async def get_map(self, name: str) -> Map[KeyType, ValueType]: |
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.
Intention is only to support also VC in near (immediate) term?
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.
Map is the only proxy included, in order to make the PR small. Other proxies, except VC, may be excluded from the beta release.
| } | ||
|
|
||
|
|
||
| class ProxyManager: |
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.
Note to others: is in proxy/__init__.py
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.
In the diff that I provided in the description I've shown that, but maybe it wasn't easy to notice.
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.
The diff was not good.
| from hazelcast.internal.asyncio_connection import Connection | ||
| from hazelcast.core import Address | ||
|
|
||
| _BUFFER_SIZE = 128000 |
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.
Best to define centrally if possible given it's used across reactors.
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.
I think they should be independent with each other.
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.
The other constant hasn't been changed for ~4 years, same value.
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.
There's not a big probability that it will change.
But I would either have to import it from hazelcast.reactor, or refactor the code so both the asyncore and the asyncio reactor imported it from a common module.
That either introduces a dependency between those reactor modules, or require changes in the "old" Python code, which I tried to avoid.
| def shutdown(self): | ||
| if not self._is_live: | ||
| return | ||
| # TODO: cancel tasks |
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.
compared to reactor.py is this correct?
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.
start, shutdown are not necessary for the AsyncioReactor.
Removed them in the 3rd PR with this commit:
58783dc
This is the initial asyncio support.
asynciomodule which contains public asyncio APIinternalmodule andinternal/asyncio_modules, which contains the private asyncio API/implementation.tests/integration/asyncio/authentication_teststests/integration/asyncio/backup_acks_teststests/integration/asyncio/client_test(one test is not ported, due to its Topic DDS dependency)tests/integration/asyncio/proxy/map_testMost of the code in this PR was duplicated to the
internalmodule by prefixing them withasyncio_. For exampleROOT/cluster.pywas duplicated/modifed asinternal/asyncio_cluster.pyHere is the diff between modules in this PR vs their counterparts in the old API:
https://gist.github.com/yuce/56e79a29a1d4d1d996788381d489c0a4