Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions sdks/python/pmxt/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""

import json
import logging
import os
import re
import sys
Expand All @@ -26,6 +27,9 @@
from pmxt_internal.api.default_api import DefaultApi
from pmxt_internal.exceptions import ApiException


logger = logging.getLogger(__name__)

from .models import (
UnifiedMarket,
UnifiedEvent,
Expand Down Expand Up @@ -461,8 +465,8 @@ def _extract_api_error(self, e: Exception) -> str:
return error_detail.get("message", str(e))
elif isinstance(error_detail, str):
return error_detail
except (json.JSONDecodeError, KeyError, TypeError, ValueError):
pass
except (json.JSONDecodeError, KeyError, TypeError, ValueError) as exc:
logger.debug("Unable to parse PMXT API error response body", exc_info=exc)
return str(e)

def _parse_api_exception(self, e: Exception) -> PmxtError:
Expand Down
20 changes: 12 additions & 8 deletions sdks/python/pmxt/server_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import os
import json
import logging
import time
import subprocess
import shutil
Expand All @@ -25,6 +26,9 @@
import urllib.error


logger = logging.getLogger(__name__)


class ServerManager:
"""
Manages the PMXT sidecar server lifecycle.
Expand Down Expand Up @@ -153,8 +157,8 @@ def normalize_version(v: str) -> str:
# This allows 1.0.0 and 1.0.0-b4 to coexist in dev
if expected_base != server_base:
return True
except (OSError, json.JSONDecodeError, AttributeError, KeyError, TypeError, ValueError):
pass
except (OSError, json.JSONDecodeError, AttributeError, KeyError, TypeError, ValueError) as exc:
logger.debug("Unable to compare sidecar server version", exc_info=exc)

return False

Expand Down Expand Up @@ -289,13 +293,13 @@ def _kill_orphan_sidecars(self) -> None:
pid = int(line.strip())
try:
os.kill(pid, _signal.SIGTERM)
except (OSError, ProcessLookupError):
pass
except (OSError, ProcessLookupError) as exc:
logger.debug("Unable to terminate orphaned PMXT sidecar pid %s", pid, exc_info=exc)

if result.stdout.strip():
time.sleep(0.5)
except (OSError, subprocess.TimeoutExpired, ValueError):
pass
except (OSError, subprocess.TimeoutExpired, ValueError) as exc:
logger.debug("Unable to scan or terminate orphaned PMXT sidecars", exc_info=exc)

def _kill_old_server(self) -> None:
"""Kill the currently running server (Internal)."""
Expand All @@ -312,8 +316,8 @@ def _kill_old_server(self) -> None:
import signal
os.kill(pid, signal.SIGTERM)
time.sleep(0.5)
except (OSError, subprocess.TimeoutExpired):
pass
except (OSError, subprocess.TimeoutExpired) as exc:
logger.debug("Unable to terminate PMXT sidecar pid %s", pid, exc_info=exc)

# Verify the process is actually dead; escalate to SIGKILL if not
if os.name != 'nt':
Expand Down
Loading