UncountablePythonSDK 0.0.81__py3-none-any.whl → 0.0.83__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.

Potentially problematic release.


This version of UncountablePythonSDK might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: UncountablePythonSDK
3
- Version: 0.0.81
3
+ Version: 0.0.83
4
4
  Summary: Uncountable SDK
5
5
  Project-URL: Homepage, https://github.com/uncountableinc/uncountable-python-sdk
6
6
  Project-URL: Repository, https://github.com/uncountableinc/uncountable-python-sdk.git
@@ -92,7 +92,7 @@ uncountable/integration/cron.py,sha256=6eH-kIs3sdYPCyb62_L2M7U_uQTdMTdwY5hreEJb0
92
92
  uncountable/integration/entrypoint.py,sha256=BHOYPQgKvZE6HG8Rv15MkdYl8lRkvfDgv1OdLo0oQ9Q,433
93
93
  uncountable/integration/job.py,sha256=af197JUceIKzpIN5C2z8zeZOPhIQ16ipyC6qVt1WXv0,2386
94
94
  uncountable/integration/scan_profiles.py,sha256=760zbv7O7wXxHUHqUkFBpd1Afe8hqxMPU3ugwZGdhEo,2925
95
- uncountable/integration/scheduler.py,sha256=UdcRXIxoq6CFON3uokyK5yzsKsvGxo7LmIRJ3XJIvBk,4499
95
+ uncountable/integration/scheduler.py,sha256=Q8N3QqsiS2Y48uj13Dmb027SmsMG4htrGWjiUKVFmh4,4784
96
96
  uncountable/integration/server.py,sha256=Hwi3fpdhcSK2HynI6Zwi7A3mWTTCaK_ic53M5-4IEp4,4716
97
97
  uncountable/integration/telemetry.py,sha256=bX68_a2PyG23n1QtIFxcH30JynUoovMz6HgA_jgUb1A,7132
98
98
  uncountable/integration/db/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -106,7 +106,7 @@ uncountable/integration/queue_runner/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeu
106
106
  uncountable/integration/queue_runner/job_scheduler.py,sha256=lhvcl11jyk_wg9BSc1Xyh5u8iEtsdqQFW83FPLupjQI,6189
107
107
  uncountable/integration/queue_runner/queue_runner.py,sha256=0BmYu5zHdothTevGsB-nXg6MBd1UD-WkP3h1WCKMdQg,710
108
108
  uncountable/integration/queue_runner/types.py,sha256=8qTq29BTSa5rmW6CBlBntP0pNIiDcwu1wHa78pjroS0,219
109
- uncountable/integration/queue_runner/worker.py,sha256=EMDtdObowaq0aHndH1bBmlSIOih0jF3Gcn7Yl6NNeOM,4265
109
+ uncountable/integration/queue_runner/worker.py,sha256=WRh_EeGyCPr72v4QL17m6Iu-ipB3T0mhc7nulILf59E,4535
110
110
  uncountable/integration/queue_runner/command_server/__init__.py,sha256=gQPVILGpWzCr2i5GJyoqna7AOSFvtn4tav69gB78mTQ,571
111
111
  uncountable/integration/queue_runner/command_server/command_client.py,sha256=DJb0TUVFkiiLBEQzHSN94sTRnuEbutNEgdN39XmnOXI,2046
112
112
  uncountable/integration/queue_runner/command_server/command_server.py,sha256=yyXryhiEC2eGS0yFElLGsVzSKwOuYvj-zp22jQorkv0,2138
@@ -286,7 +286,7 @@ uncountable/types/api/triggers/__init__.py,sha256=gCgbynxG3jA8FQHzercKtrHKHkiIKr
286
286
  uncountable/types/api/triggers/run_trigger.py,sha256=-oZgPyn43xEKSCs81DVNzwaYMCdRJxbM9GY6fsqKwf4,1090
287
287
  uncountable/types/api/uploader/__init__.py,sha256=gCgbynxG3jA8FQHzercKtrHKHkiIKr8APdZYUniAor8,55
288
288
  uncountable/types/api/uploader/invoke_uploader.py,sha256=6mwVG136oLp9JcbB2I-kZnrcm3aeZzYZB-SFjEImY2o,1314
289
- UncountablePythonSDK-0.0.81.dist-info/METADATA,sha256=hfFny-tLIUG0nrKcCY0eAxGDFgo-Q7wUXyqSczrBKpU,2051
290
- UncountablePythonSDK-0.0.81.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
291
- UncountablePythonSDK-0.0.81.dist-info/top_level.txt,sha256=1UVGjAU-6hJY9qw2iJ7nCBeEwZ793AEN5ZfKX9A1uj4,31
292
- UncountablePythonSDK-0.0.81.dist-info/RECORD,,
289
+ UncountablePythonSDK-0.0.83.dist-info/METADATA,sha256=ZyKbekQPHy3xFv8qqoVkAB5XWGyi8pX8XD15NY1GjIc,2051
290
+ UncountablePythonSDK-0.0.83.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
291
+ UncountablePythonSDK-0.0.83.dist-info/top_level.txt,sha256=1UVGjAU-6hJY9qw2iJ7nCBeEwZ793AEN5ZfKX9A1uj4,31
292
+ UncountablePythonSDK-0.0.83.dist-info/RECORD,,
@@ -2,6 +2,8 @@ import asyncio
2
2
  from concurrent.futures import ProcessPoolExecutor
3
3
  from dataclasses import dataclass
4
4
 
5
+ from opentelemetry.trace import get_current_span
6
+
5
7
  from uncountable.core.async_batch import AsyncBatchProcessor
6
8
  from uncountable.integration.construct_client import construct_uncountable_client
7
9
  from uncountable.integration.executors.executors import execute_job
@@ -9,7 +11,7 @@ from uncountable.integration.job import JobArguments
9
11
  from uncountable.integration.queue_runner.datastore.interface import Datastore
10
12
  from uncountable.integration.queue_runner.types import ListenQueue, ResultQueue
11
13
  from uncountable.integration.scan_profiles import load_profiles
12
- from uncountable.integration.telemetry import JobLogger, get_otel_tracer
14
+ from uncountable.integration.telemetry import JobLogger, Logger, get_otel_tracer
13
15
  from uncountable.types import base_t, job_definition_t, queued_job_t
14
16
 
15
17
 
@@ -28,19 +30,24 @@ class Worker:
28
30
  self.datastore = datastore
29
31
 
30
32
  async def run_worker_loop(self) -> None:
33
+ logger = Logger(get_current_span())
31
34
  while True:
32
- queued_job = await self.listen_queue.get()
33
- self.datastore.increment_num_attempts(queued_job.queued_job_uuid)
34
- loop = asyncio.get_event_loop()
35
- result = await loop.run_in_executor(
36
- self.process_pool, run_queued_job, queued_job
37
- )
38
- assert isinstance(result, job_definition_t.JobResult)
39
- await self.result_queue.put(
40
- queued_job_t.QueuedJobResult(
41
- job_result=result, queued_job_uuid=queued_job.queued_job_uuid
35
+ try:
36
+ queued_job = await self.listen_queue.get()
37
+ self.datastore.increment_num_attempts(queued_job.queued_job_uuid)
38
+ loop = asyncio.get_event_loop()
39
+ result = await loop.run_in_executor(
40
+ self.process_pool, run_queued_job, queued_job
42
41
  )
43
- )
42
+ assert isinstance(result, job_definition_t.JobResult)
43
+ await self.result_queue.put(
44
+ queued_job_t.QueuedJobResult(
45
+ job_result=result, queued_job_uuid=queued_job.queued_job_uuid
46
+ )
47
+ )
48
+ except BaseException as e:
49
+ logger.log_exception(e)
50
+ raise e
44
51
 
45
52
 
46
53
  @dataclass(kw_only=True)
@@ -36,6 +36,14 @@ class ProcessInfo:
36
36
  def pid(self) -> int | None:
37
37
  return self.process.pid
38
38
 
39
+ @property
40
+ def exitcode(self) -> int | None:
41
+ match self.process:
42
+ case multiprocessing.Process():
43
+ return self.process.exitcode
44
+ case subprocess.Popen():
45
+ return self.process.poll()
46
+
39
47
 
40
48
  def handle_shutdown(logger: Logger, processes: list[ProcessInfo]) -> None:
41
49
  logger.log_info("received shutdown command, shutting down sub-processes")
@@ -77,7 +85,7 @@ def check_process_alive(logger: Logger, processes: list[ProcessInfo]) -> None:
77
85
  for proc_info in processes:
78
86
  if not proc_info.is_alive:
79
87
  logger.log_error(
80
- f"process {proc_info.name} shut down unexpectedly! shutting down scheduler"
88
+ f"process {proc_info.name} shut down unexpectedly! shutting down scheduler; exit code is {proc_info.exitcode}"
81
89
  )
82
90
  handle_shutdown(logger, processes)
83
91
  sys.exit(1)