pydocket 0.1.3__tar.gz → 0.1.4__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.

Potentially problematic release.


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

Files changed (51) hide show
  1. {pydocket-0.1.3 → pydocket-0.1.4}/PKG-INFO +1 -1
  2. {pydocket-0.1.3 → pydocket-0.1.4}/src/docket/docket.py +5 -2
  3. {pydocket-0.1.3 → pydocket-0.1.4}/src/docket/worker.py +1 -4
  4. {pydocket-0.1.3 → pydocket-0.1.4}/tests/cli/test_snapshot.py +39 -0
  5. {pydocket-0.1.3 → pydocket-0.1.4}/.cursor/rules/general.mdc +0 -0
  6. {pydocket-0.1.3 → pydocket-0.1.4}/.cursor/rules/python-style.mdc +0 -0
  7. {pydocket-0.1.3 → pydocket-0.1.4}/.github/codecov.yml +0 -0
  8. {pydocket-0.1.3 → pydocket-0.1.4}/.github/workflows/chaos.yml +0 -0
  9. {pydocket-0.1.3 → pydocket-0.1.4}/.github/workflows/ci.yml +0 -0
  10. {pydocket-0.1.3 → pydocket-0.1.4}/.github/workflows/publish.yml +0 -0
  11. {pydocket-0.1.3 → pydocket-0.1.4}/.gitignore +0 -0
  12. {pydocket-0.1.3 → pydocket-0.1.4}/.pre-commit-config.yaml +0 -0
  13. {pydocket-0.1.3 → pydocket-0.1.4}/LICENSE +0 -0
  14. {pydocket-0.1.3 → pydocket-0.1.4}/README.md +0 -0
  15. {pydocket-0.1.3 → pydocket-0.1.4}/chaos/README.md +0 -0
  16. {pydocket-0.1.3 → pydocket-0.1.4}/chaos/__init__.py +0 -0
  17. {pydocket-0.1.3 → pydocket-0.1.4}/chaos/driver.py +0 -0
  18. {pydocket-0.1.3 → pydocket-0.1.4}/chaos/producer.py +0 -0
  19. {pydocket-0.1.3 → pydocket-0.1.4}/chaos/run +0 -0
  20. {pydocket-0.1.3 → pydocket-0.1.4}/chaos/tasks.py +0 -0
  21. {pydocket-0.1.3 → pydocket-0.1.4}/pyproject.toml +0 -0
  22. {pydocket-0.1.3 → pydocket-0.1.4}/src/docket/__init__.py +0 -0
  23. {pydocket-0.1.3 → pydocket-0.1.4}/src/docket/__main__.py +0 -0
  24. {pydocket-0.1.3 → pydocket-0.1.4}/src/docket/annotations.py +0 -0
  25. {pydocket-0.1.3 → pydocket-0.1.4}/src/docket/cli.py +0 -0
  26. {pydocket-0.1.3 → pydocket-0.1.4}/src/docket/dependencies.py +0 -0
  27. {pydocket-0.1.3 → pydocket-0.1.4}/src/docket/execution.py +0 -0
  28. {pydocket-0.1.3 → pydocket-0.1.4}/src/docket/instrumentation.py +0 -0
  29. {pydocket-0.1.3 → pydocket-0.1.4}/src/docket/py.typed +0 -0
  30. {pydocket-0.1.3 → pydocket-0.1.4}/src/docket/tasks.py +0 -0
  31. {pydocket-0.1.3 → pydocket-0.1.4}/telemetry/.gitignore +0 -0
  32. {pydocket-0.1.3 → pydocket-0.1.4}/telemetry/start +0 -0
  33. {pydocket-0.1.3 → pydocket-0.1.4}/telemetry/stop +0 -0
  34. {pydocket-0.1.3 → pydocket-0.1.4}/tests/__init__.py +0 -0
  35. {pydocket-0.1.3 → pydocket-0.1.4}/tests/cli/__init__.py +0 -0
  36. {pydocket-0.1.3 → pydocket-0.1.4}/tests/cli/conftest.py +0 -0
  37. {pydocket-0.1.3 → pydocket-0.1.4}/tests/cli/test_module.py +0 -0
  38. {pydocket-0.1.3 → pydocket-0.1.4}/tests/cli/test_parsing.py +0 -0
  39. {pydocket-0.1.3 → pydocket-0.1.4}/tests/cli/test_striking.py +0 -0
  40. {pydocket-0.1.3 → pydocket-0.1.4}/tests/cli/test_tasks.py +0 -0
  41. {pydocket-0.1.3 → pydocket-0.1.4}/tests/cli/test_version.py +0 -0
  42. {pydocket-0.1.3 → pydocket-0.1.4}/tests/cli/test_worker.py +0 -0
  43. {pydocket-0.1.3 → pydocket-0.1.4}/tests/cli/test_workers.py +0 -0
  44. {pydocket-0.1.3 → pydocket-0.1.4}/tests/conftest.py +0 -0
  45. {pydocket-0.1.3 → pydocket-0.1.4}/tests/test_dependencies.py +0 -0
  46. {pydocket-0.1.3 → pydocket-0.1.4}/tests/test_docket.py +0 -0
  47. {pydocket-0.1.3 → pydocket-0.1.4}/tests/test_fundamentals.py +0 -0
  48. {pydocket-0.1.3 → pydocket-0.1.4}/tests/test_instrumentation.py +0 -0
  49. {pydocket-0.1.3 → pydocket-0.1.4}/tests/test_striking.py +0 -0
  50. {pydocket-0.1.3 → pydocket-0.1.4}/tests/test_worker.py +0 -0
  51. {pydocket-0.1.3 → pydocket-0.1.4}/uv.lock +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pydocket
3
- Version: 0.1.3
3
+ Version: 0.1.4
4
4
  Summary: A distributed background task system for Python functions
5
5
  Project-URL: Homepage, https://github.com/chrisguidry/docket
6
6
  Project-URL: Bug Tracker, https://github.com/chrisguidry/docket/issues
@@ -184,12 +184,15 @@ class Docket:
184
184
  self.url,
185
185
  single_connection_client=True,
186
186
  )
187
- async with redis:
187
+ await redis.__aenter__()
188
+ try:
188
189
  yield redis
190
+ finally:
191
+ await asyncio.shield(redis.__aexit__(None, None, None))
189
192
  finally:
190
193
  # redis 4.6.0 doesn't automatically disconnect and leaves connections open
191
194
  if redis:
192
- await redis.connection_pool.disconnect()
195
+ await asyncio.shield(redis.connection_pool.disconnect())
193
196
 
194
197
  def register(self, function: Callable[..., Awaitable[Any]]) -> None:
195
198
  from .dependencies import validate_dependencies
@@ -280,8 +280,6 @@ class Worker:
280
280
 
281
281
  for message_id, message in redeliveries:
282
282
  start_task(message_id, message)
283
- if available_slots <= 0:
284
- break
285
283
 
286
284
  if available_slots <= 0:
287
285
  continue
@@ -300,8 +298,7 @@ class Worker:
300
298
  for _, messages in new_deliveries:
301
299
  for message_id, message in messages:
302
300
  start_task(message_id, message)
303
- if available_slots <= 0:
304
- break
301
+
305
302
  except asyncio.CancelledError:
306
303
  if active_tasks: # pragma: no cover
307
304
  logger.info(
@@ -91,6 +91,45 @@ async def test_snapshot_with_running_tasks(docket: Docket, runner: CliRunner):
91
91
  assert "sleep" in result.output
92
92
  assert "test-worker" in result.output
93
93
 
94
+ worker_running.cancel()
95
+ await worker_running
96
+
97
+
98
+ async def test_snapshot_with_mixed_tasks(docket: Docket, runner: CliRunner):
99
+ """Should show both running and scheduled tasks in the snapshot"""
100
+ heartbeat = timedelta(milliseconds=20)
101
+ docket.heartbeat_interval = heartbeat
102
+
103
+ future = datetime.now(timezone.utc) + timedelta(seconds=5)
104
+ await docket.add(tasks.trace, when=future)("hi!")
105
+ for _ in range(5): # more than the concurrency allows
106
+ await docket.add(tasks.sleep)(2)
107
+
108
+ async with Worker(docket, name="test-worker", concurrency=2) as worker:
109
+ worker_running = asyncio.create_task(worker.run_until_finished())
110
+
111
+ await asyncio.sleep(0.1)
112
+
113
+ result = await asyncio.get_running_loop().run_in_executor(
114
+ None,
115
+ runner.invoke,
116
+ app,
117
+ [
118
+ "snapshot",
119
+ "--url",
120
+ docket.url,
121
+ "--docket",
122
+ docket.name,
123
+ ],
124
+ )
125
+ assert result.exit_code == 0, result.output
126
+
127
+ assert "1 workers, 2/6 running" in result.output
128
+ assert "sleep" in result.output
129
+ assert "test-worker" in result.output
130
+ assert "trace" in result.output
131
+
132
+ worker_running.cancel()
94
133
  await worker_running
95
134
 
96
135
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes