Skip to content

Commit

Permalink
Merge pull request #1026 from facebookresearch/permissive-socket-upload
Browse files Browse the repository at this point in the history
Permissive socket upload
  • Loading branch information
JackUrb committed Jun 27, 2023
2 parents b0f1167 + a4c504c commit 2cf37b0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
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

0 comments on commit 2cf37b0

Please sign in to comment.