bugstack 1.0.0__py3-none-any.whl → 1.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bugstack/client.py +8 -1
- bugstack/transport.py +35 -8
- bugstack/types.py +1 -1
- {bugstack-1.0.0.dist-info → bugstack-1.1.0.dist-info}/METADATA +2 -1
- {bugstack-1.0.0.dist-info → bugstack-1.1.0.dist-info}/RECORD +7 -7
- {bugstack-1.0.0.dist-info → bugstack-1.1.0.dist-info}/WHEEL +1 -1
- {bugstack-1.0.0.dist-info → bugstack-1.1.0.dist-info}/licenses/LICENSE +0 -0
bugstack/client.py
CHANGED
|
@@ -41,7 +41,14 @@ class BugStackClient:
|
|
|
41
41
|
)
|
|
42
42
|
|
|
43
43
|
if config.debug:
|
|
44
|
-
|
|
44
|
+
# Attach a handler directly to the bugstack logger so debug
|
|
45
|
+
# output is visible even when a WSGI server (e.g. Gunicorn)
|
|
46
|
+
# has already configured the root logger (making basicConfig a no-op).
|
|
47
|
+
if not logger.handlers:
|
|
48
|
+
handler = logging.StreamHandler(sys.stderr)
|
|
49
|
+
handler.setFormatter(logging.Formatter("%(name)s - %(levelname)s - %(message)s"))
|
|
50
|
+
logger.addHandler(handler)
|
|
51
|
+
logger.setLevel(logging.DEBUG)
|
|
45
52
|
logger.debug(
|
|
46
53
|
"[BugStack] Client initialized (endpoint=%s, dry_run=%s)",
|
|
47
54
|
config.endpoint,
|
bugstack/transport.py
CHANGED
|
@@ -5,6 +5,7 @@ from __future__ import annotations
|
|
|
5
5
|
import asyncio
|
|
6
6
|
import json
|
|
7
7
|
import logging
|
|
8
|
+
import os
|
|
8
9
|
import threading
|
|
9
10
|
import time
|
|
10
11
|
from typing import Any, Optional
|
|
@@ -53,6 +54,7 @@ class Transport:
|
|
|
53
54
|
self._queue: list[dict[str, Any]] = []
|
|
54
55
|
self._queue_lock = threading.Lock()
|
|
55
56
|
self._stop_event = threading.Event()
|
|
57
|
+
self._owner_pid = os.getpid()
|
|
56
58
|
self._start_worker()
|
|
57
59
|
|
|
58
60
|
def _start_worker(self) -> None:
|
|
@@ -67,19 +69,44 @@ class Transport:
|
|
|
67
69
|
def _worker_loop(self) -> None:
|
|
68
70
|
"""Process queued events in the background."""
|
|
69
71
|
while not self._stop_event.is_set():
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
72
|
+
try:
|
|
73
|
+
payloads: list[dict[str, Any]] = []
|
|
74
|
+
with self._queue_lock:
|
|
75
|
+
if self._queue:
|
|
76
|
+
payloads = self._queue[:]
|
|
77
|
+
self._queue.clear()
|
|
78
|
+
|
|
79
|
+
for payload in payloads:
|
|
80
|
+
self._send_with_retry(payload)
|
|
81
|
+
except Exception as exc:
|
|
82
|
+
if self._debug:
|
|
83
|
+
logger.warning("[BugStack] Worker loop error: %s", exc)
|
|
78
84
|
|
|
79
85
|
self._stop_event.wait(timeout=0.5)
|
|
80
86
|
|
|
87
|
+
def _ensure_worker_alive(self) -> None:
|
|
88
|
+
"""Restart the worker thread if it died (e.g. after os.fork in Gunicorn)."""
|
|
89
|
+
current_pid = os.getpid()
|
|
90
|
+
if current_pid != self._owner_pid:
|
|
91
|
+
# We're in a forked child — reset state and start fresh
|
|
92
|
+
if self._debug:
|
|
93
|
+
logger.debug(
|
|
94
|
+
"[BugStack] Fork detected (pid %d -> %d), restarting worker",
|
|
95
|
+
self._owner_pid, current_pid,
|
|
96
|
+
)
|
|
97
|
+
self._owner_pid = current_pid
|
|
98
|
+
self._stop_event = threading.Event()
|
|
99
|
+
self._queue_lock = threading.Lock()
|
|
100
|
+
self._start_worker()
|
|
101
|
+
elif self._worker_thread is None or not self._worker_thread.is_alive():
|
|
102
|
+
if self._debug:
|
|
103
|
+
logger.debug("[BugStack] Worker thread dead, restarting")
|
|
104
|
+
self._stop_event.clear()
|
|
105
|
+
self._start_worker()
|
|
106
|
+
|
|
81
107
|
def enqueue(self, payload: dict[str, Any]) -> None:
|
|
82
108
|
"""Add a payload to the send queue (non-blocking)."""
|
|
109
|
+
self._ensure_worker_alive()
|
|
83
110
|
with self._queue_lock:
|
|
84
111
|
# Bound the queue to prevent unbounded memory growth
|
|
85
112
|
if len(self._queue) < 100:
|
bugstack/types.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: bugstack
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.1.0
|
|
4
4
|
Summary: Official BugStack SDK for Python — capture, report, and auto-fix production errors.
|
|
5
5
|
Project-URL: Homepage, https://bugstack.dev
|
|
6
6
|
Project-URL: Documentation, https://docs.bugstack.dev/sdks/python
|
|
@@ -20,6 +20,7 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
20
20
|
Classifier: Programming Language :: Python :: 3.11
|
|
21
21
|
Classifier: Programming Language :: Python :: 3.12
|
|
22
22
|
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
23
24
|
Classifier: Topic :: Software Development :: Bug Tracking
|
|
24
25
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
25
26
|
Classifier: Typing :: Typed
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
bugstack/__init__.py,sha256=hxWsmKjDZkplU17PbET2fsMATyoa-UuRtel-C2mAyn4,3933
|
|
2
|
-
bugstack/client.py,sha256=
|
|
2
|
+
bugstack/client.py,sha256=K0xJBcvCbigmN4UbGL6Dm9aY4oR12_3Ta2swvPjZGZg,5409
|
|
3
3
|
bugstack/fingerprint.py,sha256=K43CxWzIcrm55vgIDXfsXDRDblp_Yd8pRwFd16aW7w4,2766
|
|
4
4
|
bugstack/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
-
bugstack/transport.py,sha256=
|
|
6
|
-
bugstack/types.py,sha256=
|
|
5
|
+
bugstack/transport.py,sha256=7IPQOo5vO0TOAyjw8H2OpEOcr97vFJJvti6lcwKGUqE,6880
|
|
6
|
+
bugstack/types.py,sha256=cPwEPjFiD2y43P4LyA3QowLb4UA2IAcVVVhzNI1F2no,3364
|
|
7
7
|
bugstack/integrations/__init__.py,sha256=CkfxfB9X9W3r4VOpm0PKBbLz-IiB8J4RIT96gLjKvZk,135
|
|
8
8
|
bugstack/integrations/django.py,sha256=JfFN0HsLF2Bs2E041mXpN97aiFjatCU_YhtWLJrqYnc,3002
|
|
9
9
|
bugstack/integrations/fastapi.py,sha256=VB2xMhYXhXD43xB8_1lEjfpM4dsr0hWYNMBHadOC7Fk,2924
|
|
10
10
|
bugstack/integrations/flask.py,sha256=uAQHUIqpooKnwnmQxwGNhjkRiLFq6yfIfm3UJtEAkLE,1844
|
|
11
11
|
bugstack/integrations/generic.py,sha256=UBT_F0da21C1Iv-JdrLATn6AD43gdKFawONIzeDynHQ,2082
|
|
12
|
-
bugstack-1.
|
|
13
|
-
bugstack-1.
|
|
14
|
-
bugstack-1.
|
|
15
|
-
bugstack-1.
|
|
12
|
+
bugstack-1.1.0.dist-info/METADATA,sha256=Zd-xk4xEyji5qib4T260bOiCA_sp7yA-5kp-XPbfxJ0,5848
|
|
13
|
+
bugstack-1.1.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
14
|
+
bugstack-1.1.0.dist-info/licenses/LICENSE,sha256=DDs477apGb0jQvBH36dkPnq5blv5bCqPy7TA3PWV440,1086
|
|
15
|
+
bugstack-1.1.0.dist-info/RECORD,,
|
|
File without changes
|