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

Prevent lock-up when connecting to a booting server (gmr#133) #134

Merged
merged 1 commit into from
Jul 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion rabbitpy/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,13 +310,23 @@ def _connect(self):
self._channel0.start()

# Wait for Channel0 to raise an exception or negotiate the connection
while not self._channel0.open:
timeout_start = time.time()
while time.time() < timeout_start + self.DEFAULT_TIMEOUT:

if self._channel0.open:
break

if not self._exceptions.empty():
exception = self._exceptions.get()
self._io.stop()
raise exception

time.sleep(0.01)

# Raise exception if channel not opened before timeout
if not self._channel0.open:
raise exceptions.ConnectionException

# Set the maximum frame size for channel use
self._max_frame_size = self._channel0.maximum_frame_size

Expand Down