saq 0.24.8__py3-none-any.whl → 0.24.9__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.8"
17
+ __version__ = "0.24.9"
saq/queue/postgres.py CHANGED
@@ -659,7 +659,6 @@ class PostgresQueue(Queue):
659
659
  AND queue = %(queue)s
660
660
  AND group_key IS NOT NULL
661
661
  )
662
- AND pg_try_advisory_lock({job_lock_keyspace}, lock_key)
663
662
  ORDER BY priority, scheduled
664
663
  LIMIT %(limit)s
665
664
  FOR UPDATE SKIP LOCKED
@@ -667,12 +666,11 @@ class PostgresQueue(Queue):
667
666
  UPDATE {jobs_table} SET status = 'active'
668
667
  FROM locked_job
669
668
  WHERE {jobs_table}.key = locked_job.key
670
- RETURNING job
669
+ RETURNING job, {jobs_table}.key
671
670
  """
672
671
  )
673
672
  ).format(
674
673
  jobs_table=self.jobs_table,
675
- job_lock_keyspace=self.job_lock_keyspace,
676
674
  ),
677
675
  {
678
676
  "queue": self.name,
@@ -684,8 +682,31 @@ class PostgresQueue(Queue):
684
682
  )
685
683
  results = await cursor.fetchall()
686
684
 
687
- for result in results:
688
- self._job_queue.put_nowait(self.deserialize(result[0]))
685
+ await conn.execute(
686
+ SQL(
687
+ dedent(
688
+ """
689
+ SELECT key, pg_try_advisory_lock({job_lock_keyspace}, lock_key)
690
+ FROM {jobs_table}
691
+ WHERE key = ANY(%(keys)s)
692
+ """
693
+ )
694
+ ).format(
695
+ jobs_table=self.jobs_table,
696
+ job_lock_keyspace=self.job_lock_keyspace,
697
+ ),
698
+ {"keys": [key for _, key in results]},
699
+ )
700
+ lock_acquisition_results = await cursor.fetchall()
701
+ for key, lock_acquired in lock_acquisition_results:
702
+ if not lock_acquired:
703
+ logger.error(
704
+ "Could not acquire lock for job %s. This may result in unexpected behavior",
705
+ key,
706
+ )
707
+
708
+ for job, _ in results:
709
+ self._job_queue.put_nowait(self.deserialize(job))
689
710
 
690
711
  if results:
691
712
  await self._notify(DEQUEUE)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: saq
3
- Version: 0.24.8
3
+ Version: 0.24.9
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
@@ -1,4 +1,4 @@
1
- saq/__init__.py,sha256=8Yq6PVEa09HJzvRvQV0TUGSmOPqkdsJfNGYooR-DZ10,218
1
+ saq/__init__.py,sha256=G_2GAPgXY3_BEk5HNQpH8pQf3RqSY6Mjx8ZIOSSTRtc,218
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
@@ -10,7 +10,7 @@ saq/worker.py,sha256=W9rqK_u0bbvUbdb879pvf1f-suNnesKk1TjYqHQREc8,16817
10
10
  saq/queue/__init__.py,sha256=5LgBHGylCVvrLDcjMCcI2dRRgh0BPdz2TKOdc8NMs2E,87
11
11
  saq/queue/base.py,sha256=vRSr4ExGETlkjc9bLrtqfi_A7Zsr_IQzCMyN_b70-UM,15572
12
12
  saq/queue/http.py,sha256=V9S26gJbUt5AUIR2ETasSQy4Q_K30eGtguBYHpfcLGU,7739
13
- saq/queue/postgres.py,sha256=Zb59GWPy36K6FaW3atdYOl4KBykoFVkW8S3gwX59nAc,34719
13
+ saq/queue/postgres.py,sha256=R3nQBNWk4rZyAm52lUQyqxl0g37OnGUlL_Ixo9UgV9o,35580
14
14
  saq/queue/postgres_migrations.py,sha256=gI6j-0TzlFFSWxji3Dy9aJ-llboJBm92J4tB_YZ7qI8,2080
15
15
  saq/queue/redis.py,sha256=sa_wzUUlfPw-RZ-v_cnDEJWEFyUi3sy_3YTqG4UklOA,17754
16
16
  saq/web/__init__.py,sha256=NG9LfjgJQxNft0_iZuZ3LnX1I58SfxRwKpycjazBoGE,23
@@ -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.8.dist-info/LICENSE,sha256=p208OXrLf_dMcvuRHpcinfsJdihCqKWbqtFXpw4kyW0,1065
24
- saq-0.24.8.dist-info/METADATA,sha256=SlpZba2Kq2khnXyF5ik6kjBzcY5FqwypKbn91EbrTSM,7781
25
- saq-0.24.8.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
26
- saq-0.24.8.dist-info/entry_points.txt,sha256=HkKOud1K15_DV7AEltn8G5Ua10VqIgHaZ4BQit4fdOk,42
27
- saq-0.24.8.dist-info/top_level.txt,sha256=FMrrc5EiGr4sQkEDtUMHIpomnWHL9i6xT7B6lvEh8xM,4
28
- saq-0.24.8.dist-info/RECORD,,
23
+ saq-0.24.9.dist-info/LICENSE,sha256=p208OXrLf_dMcvuRHpcinfsJdihCqKWbqtFXpw4kyW0,1065
24
+ saq-0.24.9.dist-info/METADATA,sha256=zPpbi2NsgYJVaZJk2TIJm9TVB9M3IZJoinrnV-uekOQ,7781
25
+ saq-0.24.9.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
26
+ saq-0.24.9.dist-info/entry_points.txt,sha256=HkKOud1K15_DV7AEltn8G5Ua10VqIgHaZ4BQit4fdOk,42
27
+ saq-0.24.9.dist-info/top_level.txt,sha256=FMrrc5EiGr4sQkEDtUMHIpomnWHL9i6xT7B6lvEh8xM,4
28
+ saq-0.24.9.dist-info/RECORD,,
File without changes
File without changes