Skip to content
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

Question: inside knowledge about on_connect #493

Closed
zillionare opened this issue May 19, 2022 · 3 comments
Closed

Question: inside knowledge about on_connect #493

zillionare opened this issue May 19, 2022 · 3 comments
Assignees
Labels
Done The issue discussion is exhausted and is closed w/ comment Question Issue is a result of unclear documentation or lack of documentation

Comments

@zillionare
Copy link

zillionare commented May 19, 2022

Edit by comrumino to add full documentation quote

Your service class may also define two special methods: on_connect(self, conn) and
on_disconnect(self, conn). These methods are invoked, not surprisingly, when a connection
has been established, and when it's been disconnected.

The document says on_connect is called when the connection is established. However, in rpyc we don't build connection with server explicitly, thus it's not clear to end user when the connection is established.

Does this mean connection is established every time the remote call is invoked? Or when the remote sever process is launched?

@comrumino comrumino self-assigned this May 19, 2022
@comrumino comrumino added the Question Issue is a result of unclear documentation or lack of documentation label May 19, 2022
comrumino added a commit that referenced this issue May 19, 2022
@comrumino
Copy link
Collaborator

To answer your question directly, the server when started listens on a port; when another process or computer binds to that port they are attempting to establish a connection. Assuming the connection is established successfully, the server will call on_connect next.

The new version of the documentation is hopefully more clear.

The on_connect method is invoked when a connection has been established. From the client-side perspective, on_connect is invoked each time a client successfully invokes rpyc.connect or any other function provided by the connection factory module: rpyc.utils.factory. After the connection is dead, on_disconnect is invoked (you will not be able to access remote objects inside of on_disconnect).

@comrumino comrumino added the Done The issue discussion is exhausted and is closed w/ comment label May 19, 2022
@comrumino
Copy link
Collaborator

Feel free to reopen if needed

@zillionare
Copy link
Author

clear enough and I got same conclusion by debugging. Thanks for reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Done The issue discussion is exhausted and is closed w/ comment Question Issue is a result of unclear documentation or lack of documentation
Projects
None yet
Development

No branches or pull requests

2 participants