Skip to content
This repository was archived by the owner on Jul 28, 2023. It is now read-only.

Allow websocket retries with backoff time in between #341

Merged
merged 28 commits into from
Oct 2, 2019

Conversation

lgarc15
Copy link
Contributor

@lgarc15 lgarc15 commented Sep 12, 2019

Summary

Fixes #331

Details and comments

The WebsocketClient class method get_job_status currently allows retrying once in the case of a connection closing. This PR allows the method to retry up to five times, with time in between.

@lgarc15 lgarc15 changed the title Allow retries with backoff time in between Allow websocket retries with backoff time in between Sep 12, 2019
@lgarc15 lgarc15 added the on hold Can not fix yet label Sep 24, 2019
@lgarc15 lgarc15 removed the on hold Can not fix yet label Sep 24, 2019

# Errors unrelated to websocket connection, not worth retrying.
except (WebsocketIBMQProtocolError, WebsocketTimeoutError) as ex:
raise ex
Copy link
Collaborator

Choose a reason for hiding this comment

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

You don't need to except the errors if you're just going to raise it? Or are you trying to document the possible exceptions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree! I think it would be much cleaner to simply remove them, since they are going to be raised regardless.

@lgarc15 lgarc15 added on hold Can not fix yet and removed on hold Can not fix yet labels Sep 26, 2019
@lgarc15 lgarc15 changed the title Allow websocket retries with backoff time in between [WIP] Allow websocket retries with backoff time in between Sep 30, 2019
@lgarc15 lgarc15 changed the title [WIP] Allow websocket retries with backoff time in between Allow websocket retries with backoff time in between Sep 30, 2019
@@ -101,6 +104,8 @@ def _connect(self, url: str) -> Generator[Any, None, Connect]:
was established, but the authentication failed.
WebsocketIBMQProtocolError: if the connection to the websocket
server was established, but the answer was unexpected.
SSLError: if the connection to the websocket server could not
be established due to SSL certificate errors.
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit - an SSLError might not be related to certificates; it could be other SSL errors. Also I don't know if you really need to document the SSLError, since exceptions thrown by the underlying services are generally not documented. For example, websocket.send() on line 131 can throw exceptions that are not caught nor documented.


def __init__(self, websocket_url: str, access_token: str) -> None:
self.websocket_url = websocket_url.rstrip('/')
self.access_token = access_token

@asyncio.coroutine
def _connect(self, url: str) -> Generator[Any, None, Connect]:
def _connect(self, url: str) -> Generator[Any, None, WebSocketClientProtocol]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you also update the docstring for the return type (from Connect to WebSocketClientProtocol)?

@jyu00 jyu00 merged commit 6565d5e into Qiskit:master Oct 2, 2019
@lgarc15 lgarc15 deleted the retry-websocket-backoff branch October 8, 2019 14:22
Rcuz8 pushed a commit to Rcuz8/qiskit-ibmq-provider that referenced this pull request Jun 14, 2022
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Websocket should be retried after failure
2 participants