BCDA-APS / gemviz

Data visualization for tiled
https://bcda-aps.github.io/gemviz/
Other
4 stars 0 forks source link

BUG: app crashes if requested server is not available #89

Closed prjemian closed 1 year ago

prjemian commented 1 year ago

Discovered that the app crashes out when the requested server is not responsive or not available. App should handle this gracefully.

prjemian commented 1 year ago

exception trace:

Pete@sev MINGW64 ~/Documents/projects/BCDA-APS/gemviz23 (77-crashes)
$ C:/Users/Pete/Apps/miniconda3/envs/gemviz23/python.exe c:/Users/Pete/Documents/projects/BCDA-APS/gemviz23/gemviz23/demo/app.py
Traceback (most recent call last):
  File "C:\Users\Pete\Apps\miniconda3\envs\gemviz23\Lib\site-packages\httpcore\_exceptions.py", line 10, in map_exceptions
    yield
  File "C:\Users\Pete\Apps\miniconda3\envs\gemviz23\Lib\site-packages\httpcore\_backends\sync.py", line 100, in connect_tcp
    sock = socket.create_connection(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Pete\Apps\miniconda3\envs\gemviz23\Lib\socket.py", line 851, in create_connection
    raise exceptions[0]
  File "C:\Users\Pete\Apps\miniconda3\envs\gemviz23\Lib\socket.py", line 836, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\Pete\Apps\miniconda3\envs\gemviz23\Lib\site-packages\httpx\_transports\default.py", line 60, in map_httpcore_exceptions
    yield
  File "C:\Users\Pete\Apps\miniconda3\envs\gemviz23\Lib\site-packages\httpx\_transports\default.py", line 218, in handle_request
    resp = self._pool.handle_request(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Pete\Apps\miniconda3\envs\gemviz23\Lib\site-packages\httpcore\_sync\connection_pool.py", line 262, in handle_request
    raise exc
  File "C:\Users\Pete\Apps\miniconda3\envs\gemviz23\Lib\site-packages\httpcore\_sync\connection_pool.py", line 245, in handle_request
    response = connection.handle_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Pete\Apps\miniconda3\envs\gemviz23\Lib\site-packages\httpcore\_sync\connection.py", line 92, in handle_request
    raise exc
  File "C:\Users\Pete\Apps\miniconda3\envs\gemviz23\Lib\site-packages\httpcore\_sync\connection.py", line 69, in handle_request
    stream = self._connect(request)
             ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Pete\Apps\miniconda3\envs\gemviz23\Lib\site-packages\httpcore\_sync\connection.py", line 117, in _connect
    stream = self._network_backend.connect_tcp(**kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Pete\Apps\miniconda3\envs\gemviz23\Lib\site-packages\httpcore\_backends\sync.py", line 99, in connect_tcp
    with map_exceptions(exc_map):
  File "C:\Users\Pete\Apps\miniconda3\envs\gemviz23\Lib\contextlib.py", line 155, in __exit__
    self.gen.throw(typ, value, traceback)
  File "C:\Users\Pete\Apps\miniconda3\envs\gemviz23\Lib\site-packages\httpcore\_exceptions.py", line 14, in map_exceptions
    raise to_exc(exc) from exc
httpcore.ConnectError: [WinError 10061] No connection could be made because the target machine actively refused it

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "c:\Users\Pete\Documents\projects\BCDA-APS\gemviz23\gemviz23\demo\mainwindow.py", line 92, in doOpen
    self.filter_panel.setServer(utils.connect_tiled_server(server_uri))
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\Pete\Documents\projects\BCDA-APS\gemviz23\gemviz23\demo\utils.py", line 145, in connect_tiled_server
    client = from_uri(uri, cache=Cache.in_memory(2e9))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Pete\Apps\miniconda3\envs\gemviz23\Lib\site-packages\tiled\client\constructors.py", line 65, in from_uri
    context, node_path_parts = Context.from_any_uri(
                               ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Pete\Apps\miniconda3\envs\gemviz23\Lib\site-packages\tiled\client\context.py", line 281, in from_any_uri
    context = cls(
              ^^^^
  File "C:\Users\Pete\Apps\miniconda3\envs\gemviz23\Lib\site-packages\tiled\client\context.py", line 158, in __init__
    self.server_info = self.get_json(self.api_uri)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Pete\Apps\miniconda3\envs\gemviz23\Lib\site-packages\tiled\client\context.py", line 595, in get_json
    self.get_content(
  File "C:\Users\Pete\Apps\miniconda3\envs\gemviz23\Lib\site-packages\tiled\client\context.py", line 556, in get_content
    response = self.http_client.send(request, stream=stream, **send_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Pete\Apps\miniconda3\envs\gemviz23\Lib\site-packages\httpx\_client.py", line 901, in send
    response = self._send_handling_auth(
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Pete\Apps\miniconda3\envs\gemviz23\Lib\site-packages\httpx\_client.py", line 929, in _send_handling_auth
    response = self._send_handling_redirects(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Pete\Apps\miniconda3\envs\gemviz23\Lib\site-packages\httpx\_client.py", line 966, in _send_handling_redirects
    response = self._send_single_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Pete\Apps\miniconda3\envs\gemviz23\Lib\site-packages\httpx\_client.py", line 1002, in _send_single_request
    response = transport.handle_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Pete\Apps\miniconda3\envs\gemviz23\Lib\site-packages\httpx\_transports\default.py", line 217, in handle_request
    with map_httpcore_exceptions():
  File "C:\Users\Pete\Apps\miniconda3\envs\gemviz23\Lib\contextlib.py", line 155, in __exit__
    self.gen.throw(typ, value, traceback)
  File "C:\Users\Pete\Apps\miniconda3\envs\gemviz23\Lib\site-packages\httpx\_transports\default.py", line 77, in map_httpcore_exceptions
    raise mapped_exc(message) from exc
httpx.ConnectError: [WinError 10061] No connection could be made because the target machine actively refused it
(gemviz23)
prjemian commented 1 year ago

While testing a possible resolution to this issue, encountered a different problem (#77) that will be resolved by merging #83. Skipping that for now to avoid creation of a potential merge conflict.