Skip to content

Add sync multiprocess support #3972

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

Merged

Conversation

liorsve
Copy link
Contributor

@liorsve liorsve commented May 25, 2025

Issue link

This Pull Request is linked to issue : #239

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one issue.
  • Commit message has a detailed description of what changed and why.
  • Tests are added or updated.
  • [] CHANGELOG.md and documentation files are updated.
  • Destination branch is correct - main or release
  • Create merge commit if merging release branch into main, squash otherwise.

@liorsve liorsve requested a review from a team as a code owner May 25, 2025 15:06
@liorsve liorsve force-pushed the sync-multiprocess-support branch 5 times, most recently from 4a810ec to fd00e61 Compare May 26, 2025 09:51
@liorsve liorsve force-pushed the python-sync-client branch 3 times, most recently from 122d41d to dda9443 Compare May 26, 2025 14:40

return self

def _reset_client_connection(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

_reset_client_connection -> _reset_client
connection is misleading here
please add documentation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

deleted _reset_client_connection

conn_req = config._create_a_protobuf_conn_request(
cluster_mode=type(config) is GlideClusterClientConfiguration

os.register_at_fork(after_in_child=self._reset_client_connection)
Copy link
Collaborator

Choose a reason for hiding this comment

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

so why do we need both _create_new_core_client and _reset_client_connection? can't we just register _create_new_core_client?

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 reason at all, just a leftover from previous iterations where I had different code there and I didn't notice it has no use now
deleted _reset_client_connection

def _reset_client_connection(self):
self._create_new_core_client()

def _create_new_core_client(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: _create_core_client

except OSError as e:
pytest.fail(f"Fork failed: {e}")

if pid == 0:
Copy link
Collaborator

Choose a reason for hiding this comment

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

use get_pid() before you fork and compare it to it, it would be more robust

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hope I fixed as you meant

Copy link
Collaborator

@barshaul barshaul left a comment

Choose a reason for hiding this comment

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

some comments

@liorsve liorsve force-pushed the sync-multiprocess-support branch from fd00e61 to a9f977d Compare May 27, 2025 10:42
liorsve added 2 commits May 27, 2025 13:22
Signed-off-by: Lior Sventitzky <[email protected]>
Signed-off-by: Lior Sventitzky <[email protected]>
@liorsve liorsve force-pushed the sync-multiprocess-support branch from a9f977d to 55dab5b Compare May 27, 2025 13:27
@liorsve liorsve merged commit 56518ec into valkey-io:python-sync-client May 27, 2025
18 checks passed
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.

2 participants