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

Permissive socket upload #1026

Merged
merged 2 commits into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
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
15 changes: 15 additions & 0 deletions mephisto/abstractions/architects/channels/websocket_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

logger = get_logger(name=__name__)

MAX_RETRIES = 3


class WebsocketChannel(Channel):
"""
Expand Down Expand Up @@ -55,6 +57,7 @@ def __init__(
self._is_alive = False
self._is_closed = False
self._socket_task: Optional[asyncio.Task] = None
self._retries = MAX_RETRIES

def is_closed(self):
"""
Expand Down Expand Up @@ -161,6 +164,18 @@ async def run_socket():
f"Unhandled OSError exception in socket {e}, attempting restart"
)
await asyncio.sleep(0.2)
except websockets.exceptions.InvalidStatusCode as e:
if self._retries == 0:
raise ConnectionRefusedError(
"Could not connect after retries"
) from e
curr_retry = MAX_RETRIES - self._retries
logger.exception(
f"Status code error {repr(e)}, attempting retry {curr_retry}",
exc_info=True,
)
await asyncio.sleep(1 + curr_retry)
self._retries += 1
except Exception as e:
logger.exception(f"Unhandled exception in socket {e}, {repr(e)}")
if self._is_closed:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/bash

echo "Installing basic requirements..."
sudo yum update -y >> /home/ec2-user/routing_server/setup/setup_log.txt 2>&1
# Following is commented out until the aws linux2 repo is no longer lagging
# sudo yum update -y >> /home/ec2-user/routing_server/setup/setup_log.txt 2>&1
sudo yum install -y httpd >> /home/ec2-user/routing_server/setup/setup_log.txt 2>&1

echo "Downloading Node..."
Expand Down
Loading