Skip to content

Conversation

@yuce
Copy link
Contributor

@yuce yuce commented Dec 5, 2025

I've improved the stability of the asyncio client in this PR.

  • Added support for non-blocking Hazelcast Cloud address resolution
  • Ported connection_manager_test.py to asyncio
  • Refactored AsyncioConnection to be more reliable by porting more logic from AsyncoreConnection.
  • Run all VectorCollection tests for 5.6.0

@codecov-commenter
Copy link

codecov-commenter commented Dec 5, 2025

Codecov Report

❌ Patch coverage is 57.24138% with 62 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.57%. Comparing base (80119dd) to head (f724d2d).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
hazelcast/internal/asyncio_reactor.py 63.04% 34 Missing ⚠️
hazelcast/internal/asyncio_discovery.py 0.00% 28 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #754      +/-   ##
==========================================
- Coverage   94.73%   94.57%   -0.16%     
==========================================
  Files         392      393       +1     
  Lines       24959    25074     +115     
==========================================
+ Hits        23645    23714      +69     
- Misses       1314     1360      +46     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

response = await self._authenticate(connection)
translated = await self._translate_member_address(member)
connection = self._create_connection(translated)
await connection._create_task
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason not returning a "future" on self._create_connection but instead of doing it on connection._create_task ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_create_connection returns the AsyncioConnection object itself, since it is used in _authenticate.
_create_connection also creates two tasks, one is for creating the socket, and the second is for checking whether the connection was established in time.
We await on connection._create_task to make sure the socket is created before carrying on with authentication.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still, it looks odd to me. Instead of tracking an internal field, I would make it a method which is called after initializing the object. Also, I think both connect and auth can be combined into one. Nevertheless, I won't stand on it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_create_task may not be the best name.
It is not like "create this task", but "task named create".
Even if I add a method like:

async def ensure_connected(self):
   await self._create_task

I would still have to call it with await:

connection = self._create_connection(translated)
await connection.ensure_connected()

So that doesn't buy us much.

self, connection_manager, connection_id, address: Address, network_config, message_callback
):
return await AsyncioConnection.create_and_connect(
return AsyncioConnection.create_and_connect(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why removed async?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The create_and_connect is not async anymore, it just returns the connection, without waiting for the connection to be established.

async def _create_connection(self, config, address):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.setblocking(False)
sock.settimeout(0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

timeout 0? dont we have setting for it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the timeout is set to 0 to immediately return from socket creation.
It's the same with the asyncore client.

The connection_timeout is a separate setting.

@yuce yuce requested review from emreyigit and ihsandemir December 8, 2025 11:21
@yuce
Copy link
Contributor Author

yuce commented Dec 8, 2025

@ihsandemir I'll merge this, but I'll address any concerns in a separate PR if necessary.

@yuce yuce merged commit 41d65f9 into hazelcast:master Dec 8, 2025
11 checks passed
@yuce yuce deleted the asyncio-module-cloud-support branch December 8, 2025 14:38
@yuce yuce added this to the 5.6.0 milestone Dec 10, 2025
@yuce yuce changed the title Asyncio Module Cloud Support [HZ-5276] Asyncio Module Cloud Support Dec 10, 2025
@yuce yuce changed the title [HZ-5276] Asyncio Module Cloud Support [HZ-5276] [HZ-5277] Asyncio Module Cloud Support Dec 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants