Skip to content
This repository has been archived by the owner on Oct 8, 2023. It is now read-only.

wait_server_available method ... #206

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vishalhkd
Copy link

Move the socket.socket() initialization to be inside the while loop. Having it outside initiates it only once and when closed inside the while loop, it starts to raise 'Bad File Descriptor' error since the socket is closed.

Before submitting a pull request, please make sure the following is done:

  1. Fork the repository and create your branch from master.

  2. Run the build.py and test.py scripts.

  3. If you are fixing something, add tests that fail in the current version and pass in yours.

  4. If you're developing a new feature open an issue first to discuss it. Some features may be useful to you but harmful to others be it because of performance, new dependencies or different perspectives.

  5. One more time: Don't forget to add tests.

  6. Ensure the entire test suite is passing and overall performance is not degraded.

Move the socket.socket() initialization to be inside the while loop. Having it outside initiates it only once and when closed inside the while loop, it starts to raise 'Bad File Descriptor' error since the socket is closed.
@@ -131,9 +131,12 @@ def wait_server_available(host: str, port: int, timeout: int=10) -> None:
:param port: TCP port used to connect.
:return:
"""
sock = socket.socket()
sock.settimeout(timeout)
while timeout > 0:
Copy link

Choose a reason for hiding this comment

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

The sockwill be undefined, if arg timeoutis less than 0 when func is calling.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants