Skip to content

Commit

Permalink
Try fixing flakyness of Plexus4 and others
Browse files Browse the repository at this point in the history
  • Loading branch information
progval committed May 1, 2022
1 parent 7ccf5a4 commit 627f0b6
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions irctest/cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,30 @@
T = TypeVar("T")


def retry(f: TCallable) -> TCallable:
"""Retry the function if it raises ConnectionClosed; as a workaround for flaky
connection, such as::
1: connects to server.
1 -> S: NICK foo
1 -> S: USER username * * :Realname
S -> 1: :My.Little.Server NOTICE * :*** Found your hostname (cached)
S -> 1: :My.Little.Server NOTICE * :*** Checking Ident
S -> 1: :My.Little.Server NOTICE * :*** No Ident response
S -> 1: ERROR :Closing Link: cpu-pool.com (Use a different port)
"""

@functools.wraps(f)
def newf(*args, **kwargs): # type: ignore
try:
return f(*args, **kwargs)
except ConnectionClosed:
time.sleep(1)
return f(*args, **kwargs)

return newf # type: ignore


class ChannelJoinException(Exception):
def __init__(self, code: str, params: List[str]):
super().__init__(f"Failed to join channel ({code}): {params}")
Expand Down Expand Up @@ -661,6 +685,7 @@ def authenticateClient(
m = self.getRegistrationMessage(client)
self.assertIn(m.command, ["900", "903"], str(m))

@retry
def connectClient(
self,
nick: str,
Expand Down

0 comments on commit 627f0b6

Please sign in to comment.