is there a way to check connection is established in asyncore?
once asyncore.loop() is called, how can I disconnect the communication between server?
can i just simply call close()?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Once asyncore.loop() is called, the control is handed over to event loop that runs.
Any code after the asyncore.loop() will be called only after the event loop has been shut down.
Event loop will react to various events and call handlers. To shutdown the event loop, you must call to stop in one of the event handler where it makes sense.
For ex: Take a look at the following example.
Code from : http://www.mechanicalcat.net/richard/log/Python/A_simple_asyncore__echo_server__example
self.close is called inside one of the event handler – handle_read. In this case after the data has been received from the server. it disconnects itself.
References: