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

Bug: Unhandled exception in rest_client_base.py #71

Open
gohm-tech opened this issue Aug 8, 2022 · 0 comments
Open

Bug: Unhandled exception in rest_client_base.py #71

gohm-tech opened this issue Aug 8, 2022 · 0 comments

Comments

@gohm-tech
Copy link

gohm-tech commented Aug 8, 2022

When there is a problem with network (or no connection at all), the post function inside login function (rest_client_base.py file) is creating unhandled exceptions. I thing this post function needs timeout, and this function needs to be encapsulated in a try except condition.
tb_rest_client version is 1.3.2

The steps to reproduce:
1- Without and active internet connection, call rest_client.login(username=self.username, password=self.password)
2- you will get error like this:

Aug  8 14:05:33 gasgw-b827ebcd0c4f python3[3420]:     conn.connect()
Aug  8 14:05:33 gasgw-b827ebcd0c4f python3[3420]:   File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 353, in connect
Aug  8 14:05:33 gasgw-b827ebcd0c4f python3[3420]:     conn = self._new_conn()
Aug  8 14:05:33 gasgw-b827ebcd0c4f python3[3420]:   File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 181, in _new_conn
Aug  8 14:05:33 gasgw-b827ebcd0c4f python3[3420]:     raise NewConnectionError(
Aug  8 14:05:33 gasgw-b827ebcd0c4f python3[3420]: urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0xb43c71c0>: Failed to establish a new connection: [Errno 113] No route to host
Aug  8 14:05:33 gasgw-b827ebcd0c4f python3[3420]: During handling of the above exception, another exception occurred:
Aug  8 14:05:33 gasgw-b827ebcd0c4f python3[3420]: Traceback (most recent call last):
Aug  8 14:05:33 gasgw-b827ebcd0c4f python3[3420]:   File "/usr/lib/python3/dist-packages/requests/adapters.py", line 439, in send
Aug  8 14:05:33 gasgw-b827ebcd0c4f python3[3420]:     resp = conn.urlopen(
Aug  8 14:05:33 gasgw-b827ebcd0c4f python3[3420]:   File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 755, in urlopen
Aug  8 14:05:33 gasgw-b827ebcd0c4f python3[3420]:     retries = retries.increment(
Aug  8 14:05:33 gasgw-b827ebcd0c4f python3[3420]:   File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 574, in increment
Aug  8 14:05:33 gasgw-b827ebcd0c4f python3[3420]:     raise MaxRetryError(_pool, url, error or ResponseError(cause))
Aug  8 14:05:33 gasgw-b827ebcd0c4f python3[3420]: urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='[load.molisens.com](http://load.molisens.com/)', port=443): Max retries exceeded with url: /api/auth/login (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0xb43c71c0>: Failed to establish a new connection: [Errno 113] No route to host'))
Aug  8 14:05:33 gasgw-b827ebcd0c4f python3[3420]: During handling of the above exception, another exception occurred:
Aug  8 14:05:33 gasgw-b827ebcd0c4f python3[3420]: Traceback (most recent call last):
Aug  8 14:05:33 gasgw-b827ebcd0c4f python3[3420]:   File "/usr/local/lib/python3.9/dist-packages/tb_rest_client/rest_client_base.py", line 56, in run
Aug  8 14:05:33 gasgw-b827ebcd0c4f python3[3420]:     self.login(self.username, self.password)
Aug  8 14:05:33 gasgw-b827ebcd0c4f python3[3420]:   File "/usr/local/lib/python3.9/dist-packages/tb_rest_client/rest_client_base.py", line 83, in login
Aug  8 14:05:33 gasgw-b827ebcd0c4f python3[3420]:     token_json = post(self.base_url + "/api/auth/login", json={"username": username, "password": password},
Aug  8 14:05:33 gasgw-b827ebcd0c4f python3[3420]:   File "/usr/lib/python3/dist-packages/requests/api.py", line 119, in post
Aug  8 14:05:33 gasgw-b827ebcd0c4f python3[3420]:     return request('post', url, data=data, json=json, **kwargs)
Aug  8 14:05:33 gasgw-b827ebcd0c4f python3[3420]:   File "/usr/lib/python3/dist-packages/requests/api.py", line 61, in request
Aug  8 14:05:33 gasgw-b827ebcd0c4f python3[3420]:     return session.request(method=method, url=url, **kwargs)
Aug  8 14:05:33 gasgw-b827ebcd0c4f python3[3420]:   File "/usr/lib/python3/dist-packages/requests/sessions.py", line 542, in request
Aug  8 14:05:33 gasgw-b827ebcd0c4f python3[3420]:     resp = self.send(prep, **send_kwargs)
Aug  8 14:05:33 gasgw-b827ebcd0c4f python3[3420]:   File "/usr/lib/python3/dist-packages/requests/sessions.py", line 655, in send
Aug  8 14:05:33 gasgw-b827ebcd0c4f python3[3420]:     r = adapter.send(request, **kwargs)
Aug  8 14:05:33 gasgw-b827ebcd0c4f python3[3420]:   File "/usr/lib/python3/dist-packages/requests/adapters.py", line 516, in send
Aug  8 14:05:33 gasgw-b827ebcd0c4f python3[3420]:     raise ConnectionError(e, request=request)
@gohm-tech gohm-tech changed the title Unhandled exception in rest_client_base.py Bug: Unhandled exception in rest_client_base.py Aug 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant