tasq-client-python 0.1.16__py3-none-any.whl → 0.1.17__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.
tasq_client/client.py CHANGED
@@ -6,7 +6,7 @@ from contextlib import contextmanager
6
6
  from dataclasses import dataclass
7
7
  from queue import Empty, Queue
8
8
  from threading import Thread
9
- from typing import Any, Dict, List, Optional, Tuple
9
+ from typing import Any, Dict, Generator, List, Optional, Tuple
10
10
 
11
11
  import requests
12
12
  from requests.adapters import HTTPAdapter, Retry
@@ -36,6 +36,7 @@ class QueueCounts:
36
36
  rate: Optional[float] = None
37
37
 
38
38
  modtime: Optional[int] = None
39
+ bytes: Optional[int] = None
39
40
 
40
41
 
41
42
  class TasqClient:
@@ -93,7 +94,7 @@ class TasqClient:
93
94
  full, in which case None is returned.
94
95
  """
95
96
  return self._post_form(
96
- f"/task/push", dict(contents=contents, limit=limit), type_template=OptionalValue(str)
97
+ "/task/push", dict(contents=contents, limit=limit), type_template=OptionalValue(str)
97
98
  )
98
99
 
99
100
  def push_batch(self, ids: List[str], limit: int = 0) -> Optional[List[str]]:
@@ -130,12 +131,12 @@ class TasqClient:
130
131
  Unlike push_batch(), the ids returned by this method will never be
131
132
  None, since all tasks must be pushed.
132
133
  """
133
- assert isinstance(
134
- contents, (list, tuple)
135
- ), f"expected a list of task contents, got object of type {type(contents)}"
136
- assert (
137
- init_wait_time <= self.max_timeout
138
- ), f"wait time {init_wait_time=} should not be larger than {self.max_timeout=}"
134
+ assert isinstance(contents, (list, tuple)), (
135
+ f"expected a list of task contents, got object of type {type(contents)}"
136
+ )
137
+ assert init_wait_time <= self.max_timeout, (
138
+ f"wait time {init_wait_time=} should not be larger than {self.max_timeout=}"
139
+ )
139
140
  assert limit < 0 or limit >= len(contents)
140
141
 
141
142
  cur_wait = init_wait_time
@@ -226,7 +227,7 @@ class TasqClient:
226
227
  self._post_form("/task/keepalive", dict(id=id), supports_timeout=True)
227
228
 
228
229
  @contextmanager
229
- def pop_running_task(self) -> Optional["RunningTask"]:
230
+ def pop_running_task(self) -> Generator[Optional["RunningTask"], None, None]:
230
231
  """
231
232
  Pop a task from the queue and wrap it in a RunningTask, blocking until
232
233
  the queue is completely empty or a task is successfully popped.
@@ -257,13 +258,15 @@ class TasqClient:
257
258
  def counts(self, rate_window: int = 0) -> QueueCounts:
258
259
  """Get the number of tasks in each state within the queue."""
259
260
  data = self._get(
260
- f"/counts?window={rate_window}&includeModtime=1",
261
+ f"/counts?window={rate_window}&includeModtime=1&includeBytes=1",
261
262
  {
262
263
  "pending": int,
263
264
  "running": int,
264
265
  "expired": int,
265
266
  "completed": int,
266
267
  OptionalKey("minute_rate"): float,
268
+ OptionalKey("modtime"): int,
269
+ OptionalKey("bytes"): int,
267
270
  },
268
271
  )
269
272
  return QueueCounts(**data)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tasq-client-python
3
- Version: 0.1.16
3
+ Version: 0.1.17
4
4
  Summary: UNKNOWN
5
5
  Home-page: UNKNOWN
6
6
  License: UNKNOWN
@@ -0,0 +1,8 @@
1
+ tasq_client/__init__.py,sha256=I0ik-_c0hcVKUgx7QsE3YnoCQyAVMFKKOzoLt-jNFtE,277
2
+ tasq_client/check_type.py,sha256=t_jreI8rf6QWS9Jf105ZvUVbwFe-uL4rMg4kZk6e4cA,2795
3
+ tasq_client/check_type_test.py,sha256=bvhVaO-Bu18aI3J4Kxnb0H27fzDCKkTHVBWhjJMFMis,1433
4
+ tasq_client/client.py,sha256=Bn9koJj_pf3Iie6CmNXf_EY4An5Nduf5Ref4kY6zHkw,15332
5
+ tasq_client_python-0.1.17.dist-info/METADATA,sha256=nrhAv0mDPEPzj0V-MpuJCC0omtI5E9hWHMspmaNoYBY,168
6
+ tasq_client_python-0.1.17.dist-info/WHEEL,sha256=ewwEueio1C2XeHTvT17n8dZUJgOvyCWCt0WVNLClP9o,92
7
+ tasq_client_python-0.1.17.dist-info/top_level.txt,sha256=JUs_FTRfs_ggMu8zusU5CSXgAl-JHhrjMXxuZay-B58,12
8
+ tasq_client_python-0.1.17.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- tasq_client/__init__.py,sha256=I0ik-_c0hcVKUgx7QsE3YnoCQyAVMFKKOzoLt-jNFtE,277
2
- tasq_client/check_type.py,sha256=t_jreI8rf6QWS9Jf105ZvUVbwFe-uL4rMg4kZk6e4cA,2795
3
- tasq_client/check_type_test.py,sha256=bvhVaO-Bu18aI3J4Kxnb0H27fzDCKkTHVBWhjJMFMis,1433
4
- tasq_client/client.py,sha256=1f-BBYaiILfziZfzW3J4HOGwAgRbU80pbmlPX2J9wQE,15162
5
- tasq_client_python-0.1.16.dist-info/METADATA,sha256=Y5auv-WWFODNhED09_NvXXNcVvyq6GDUYGvlzWf-Tx8,168
6
- tasq_client_python-0.1.16.dist-info/WHEEL,sha256=ewwEueio1C2XeHTvT17n8dZUJgOvyCWCt0WVNLClP9o,92
7
- tasq_client_python-0.1.16.dist-info/top_level.txt,sha256=JUs_FTRfs_ggMu8zusU5CSXgAl-JHhrjMXxuZay-B58,12
8
- tasq_client_python-0.1.16.dist-info/RECORD,,