tasq-client-python 0.1.11__tar.gz → 0.1.12__tar.gz

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.
@@ -1,3 +1,3 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tasq-client-python
3
- Version: 0.1.11
3
+ Version: 0.1.12
@@ -4,5 +4,5 @@ setup(
4
4
  name="tasq-client-python",
5
5
  packages=["tasq_client"],
6
6
  install_requires=["requests"],
7
- version="0.1.11",
7
+ version="0.1.12",
8
8
  )
@@ -30,6 +30,10 @@ class QueueCounts:
30
30
  expired: int
31
31
  completed: int
32
32
 
33
+ # Won't be set if a time window wasn't specified in the request, or if the
34
+ # server is old enough to not support rate estimation.
35
+ rate: Optional[float] = None
36
+
33
37
 
34
38
  class TasqClient:
35
39
  """
@@ -193,16 +197,17 @@ class TasqClient:
193
197
  yield None
194
198
  return
195
199
 
196
- def counts(self) -> QueueCounts:
200
+ def counts(self, rate_window: int = 0) -> QueueCounts:
197
201
  """Get the number of tasks in each state within the queue."""
198
202
  data = self._get(
199
- "/counts",
200
- dict(
201
- pending=int,
202
- running=int,
203
- expired=int,
204
- completed=int,
205
- ),
203
+ f"/counts?window={rate_window}",
204
+ {
205
+ "pending": int,
206
+ "running": int,
207
+ "expired": int,
208
+ "completed": int,
209
+ OptionalKey("minute_rate"): float,
210
+ },
206
211
  )
207
212
  return QueueCounts(**data)
208
213
 
@@ -262,7 +267,8 @@ class TasqClient:
262
267
  )
263
268
 
264
269
  def _url_for_path(self, path: str, supports_timeout: bool) -> str:
265
- result = self.base_url + path + "?context=" + urllib.parse.quote(self.context)
270
+ separator = "?" if "?" not in path else "&"
271
+ result = self.base_url + path + separator + "context=" + urllib.parse.quote(self.context)
266
272
  if supports_timeout and self.task_timeout is not None:
267
273
  result += "&timeout=" + urllib.parse.quote(f"{self.task_timeout:f}")
268
274
  return result
@@ -1,3 +1,3 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tasq-client-python
3
- Version: 0.1.11
3
+ Version: 0.1.12