saq 0.24.10__py3-none-any.whl → 0.24.11__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.
saq/__init__.py CHANGED
@@ -14,4 +14,4 @@ __all__ = [
14
14
  "Worker",
15
15
  ]
16
16
 
17
- __version__ = "0.24.10"
17
+ __version__ = "0.24.11"
saq/queue/base.py CHANGED
@@ -28,12 +28,12 @@ if t.TYPE_CHECKING:
28
28
  from saq.types import (
29
29
  BeforeEnqueueType,
30
30
  CountKind,
31
- ListenCallback,
32
31
  DumpType,
32
+ ListenCallback,
33
33
  LoadType,
34
34
  QueueInfo,
35
- WorkerStats,
36
35
  WorkerInfo,
36
+ WorkerStats,
37
37
  )
38
38
 
39
39
 
@@ -370,7 +370,7 @@ class Queue(ABC):
370
370
  job_keys: sequence of job keys
371
371
  callback: callback function, if it returns truthy, break
372
372
  timeout: if timeout is truthy, wait for timeout seconds
373
- poll_interval: number of seconds in between poll attempts if needed
373
+ poll_interval: Number of seconds between checking job status (default 0.5)
374
374
  """
375
375
 
376
376
  async def listen() -> None:
@@ -391,7 +391,13 @@ class Queue(ABC):
391
391
  else:
392
392
  await listen()
393
393
 
394
- async def apply(self, job_or_func: str, timeout: float | None = None, **kwargs: t.Any) -> t.Any:
394
+ async def apply(
395
+ self,
396
+ job_or_func: str,
397
+ timeout: float | None = None,
398
+ poll_interval: float = 0.5,
399
+ **kwargs: t.Any,
400
+ ) -> t.Any:
395
401
  """
396
402
  Enqueue a job and wait for its result.
397
403
 
@@ -409,9 +415,12 @@ class Queue(ABC):
409
415
  Args:
410
416
  job_or_func: Same as Queue.enqueue
411
417
  timeout: If provided, how long to wait for result, else infinite (default None)
418
+ poll_interval: Number of seconds between checking job status (default 0.5)
412
419
  kwargs: Same as Queue.enqueue
413
420
  """
414
- results = await self.map(job_or_func, timeout=timeout, iter_kwargs=[kwargs])
421
+ results = await self.map(
422
+ job_or_func, timeout=timeout, poll_interval=poll_interval, iter_kwargs=[kwargs]
423
+ )
415
424
  if results:
416
425
  return results[0]
417
426
  return None
@@ -450,7 +459,7 @@ class Queue(ABC):
450
459
  return_exceptions: If False (default), an exception is immediately raised as soon as any jobs
451
460
  fail. Other jobs won't be cancelled and will continue to run.
452
461
  If True, exceptions are treated the same as successful results and aggregated in the result list.
453
- poll_interval: number of seconds in between poll attempts
462
+ poll_interval: Number of seconds between checking job status (default 0.5)
454
463
  kwargs: Default kwargs for all jobs. These will be overridden by those in iter_kwargs.
455
464
  """
456
465
  iter_kwargs = [
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: saq
3
- Version: 0.24.10
3
+ Version: 0.24.11
4
4
  Summary: Distributed Python job queue with asyncio and redis
5
5
  Home-page: https://github.com/tobymao/saq
6
6
  Author: Toby Mao
@@ -198,6 +198,9 @@ print(job.results)
198
198
  # run a job and return the result
199
199
  print(await queue.apply("test", a=2))
200
200
 
201
+ # run a job with custom polling interval to check status more frequently
202
+ print(await queue.apply("test", a=2, poll_interval=0.1))
203
+
201
204
  # Run multiple jobs concurrently and collect the results into a list
202
205
  print(await queue.map("test", [{"a": 3}, {"a": 4}]))
203
206
 
@@ -1,4 +1,4 @@
1
- saq/__init__.py,sha256=vYIFEVix-39RzyynnCqMQVZMrhIr4ns1aeJOmEXWCt0,219
1
+ saq/__init__.py,sha256=su3QNUaQuTeApvIOApyA-tqOHgXQLGx-_WrSLhrDWEg,219
2
2
  saq/__main__.py,sha256=N4RNqnCcj7eZbM3OyYaC03_6Cot-y-SxW5Hwx6fuzKU,2440
3
3
  saq/errors.py,sha256=XPJw6J3caSAho4ZybuodIbeuGjboVabLuf3NFOEE-4Q,112
4
4
  saq/job.py,sha256=X49OuSqZeN-RVmh4AonZRrwk2wU8MeukLSxrvjGLm7E,11552
@@ -8,7 +8,7 @@ saq/types.py,sha256=GhIq2BIE_Z9hA-qS-NQXh_iPICNI0NZxOzjW0vcMgFU,3196
8
8
  saq/utils.py,sha256=NdOycT-03zxjhKM8A1i0vzKnkv1UQxvy_Zt4GnO0Zd8,1721
9
9
  saq/worker.py,sha256=W9rqK_u0bbvUbdb879pvf1f-suNnesKk1TjYqHQREc8,16817
10
10
  saq/queue/__init__.py,sha256=5LgBHGylCVvrLDcjMCcI2dRRgh0BPdz2TKOdc8NMs2E,87
11
- saq/queue/base.py,sha256=wej8WBWK-S9GXYEHXTfl7Wwwm-DB3o1RB-bHMvNLfdI,15682
11
+ saq/queue/base.py,sha256=3Fc91Cgrpp1KUTRT0nPL9lroRmPCz7WGFpZkxDyMQh4,15919
12
12
  saq/queue/http.py,sha256=V9S26gJbUt5AUIR2ETasSQy4Q_K30eGtguBYHpfcLGU,7739
13
13
  saq/queue/postgres.py,sha256=7FSljVrqISV8w82cv0yWvyejMpucbucsjpu8Ntoqee4,35648
14
14
  saq/queue/postgres_migrations.py,sha256=gI6j-0TzlFFSWxji3Dy9aJ-llboJBm92J4tB_YZ7qI8,2080
@@ -20,9 +20,9 @@ saq/web/starlette.py,sha256=i38xuNcnQvWBY3jyHHu9Uo9ILSBzOwmk5Bq06c3CQzM,4432
20
20
  saq/web/static/app.js,sha256=i6PaRvBvt96LOINBdEuKkDvVeM-GA8lJiFg4jtQ3viY,7094
21
21
  saq/web/static/pico.min.css.gz,sha256=qCxIv3wWFMQ7MkvGSHQLwxio3121VvvieOkSjw6fv6o,9263
22
22
  saq/web/static/snabbdom.js.gz,sha256=zSO3Z761TB7bYNQFFEtypD0vCuqWesqPJeE5CuV4xRg,7603
23
- saq-0.24.10.dist-info/LICENSE,sha256=p208OXrLf_dMcvuRHpcinfsJdihCqKWbqtFXpw4kyW0,1065
24
- saq-0.24.10.dist-info/METADATA,sha256=iPnYOcZctuzl-5KOEWq7UoOBSexbYKFTtBvEM_KUr40,7782
25
- saq-0.24.10.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
26
- saq-0.24.10.dist-info/entry_points.txt,sha256=HkKOud1K15_DV7AEltn8G5Ua10VqIgHaZ4BQit4fdOk,42
27
- saq-0.24.10.dist-info/top_level.txt,sha256=FMrrc5EiGr4sQkEDtUMHIpomnWHL9i6xT7B6lvEh8xM,4
28
- saq-0.24.10.dist-info/RECORD,,
23
+ saq-0.24.11.dist-info/LICENSE,sha256=p208OXrLf_dMcvuRHpcinfsJdihCqKWbqtFXpw4kyW0,1065
24
+ saq-0.24.11.dist-info/METADATA,sha256=IXsF53-LGEvvPVhqPFU6ZFqvH3dNFCaeySLFRCLJHME,7913
25
+ saq-0.24.11.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
26
+ saq-0.24.11.dist-info/entry_points.txt,sha256=HkKOud1K15_DV7AEltn8G5Ua10VqIgHaZ4BQit4fdOk,42
27
+ saq-0.24.11.dist-info/top_level.txt,sha256=FMrrc5EiGr4sQkEDtUMHIpomnWHL9i6xT7B6lvEh8xM,4
28
+ saq-0.24.11.dist-info/RECORD,,
File without changes
File without changes