Skip to content

Commit

Permalink
MAINT: Move from requests to urlib3
Browse files Browse the repository at this point in the history
  • Loading branch information
bnmajor committed Jul 11, 2023
1 parent e436277 commit d3a4c1e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 2 additions & 4 deletions itkwidgets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@
register_itkwasm_imjoy_codecs()

from .viewer import Viewer, view, compare_images
from .standalone_server import standalone_viewer

__all__ = [
"Viewer",
"view",
"compare_images",
"standalone_viewer",
]

if ENVIRONMENT is not Env.JUPYTERLITE:
from .standalone_server import standalone_viewer
__all__.append("standalone_viewer")
12 changes: 7 additions & 5 deletions itkwidgets/standalone_server.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import argparse
import logging
import uuid
import os
import subprocess
import sys
import time
from pathlib import Path

import requests
from requests import RequestException
import webbrowser

import imjoy_rpc
Expand All @@ -25,7 +24,9 @@
from ngff_zarr import detect_cli_io_backend, cli_input_to_ngff_image, ConversionBackend
from pathlib import Path
from urllib.parse import parse_qs, urlencode, urlparse
from urllib3 import PoolManager, exceptions

logging.getLogger("urllib3").setLevel(logging.ERROR)

def standalone_viewer(url):
query = parse_qs(urlparse(url).query)
Expand Down Expand Up @@ -139,10 +140,11 @@ def main():
timeout = 10
while timeout > 0:
try:
response = requests.get(f"{server_url}/health/liveness")
if response.ok:
http = PoolManager()
response = http.request("GET", f"{server_url}/health/liveness")
if response.status == 200:
break
except RequestException:
except exceptions.MaxRetryError:
pass
timeout -= 0.1
time.sleep(0.1)
Expand Down

0 comments on commit d3a4c1e

Please sign in to comment.