modal 1.0.6.dev13__tar.gz → 1.0.6.dev15__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.
Files changed (184) hide show
  1. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/PKG-INFO +1 -1
  2. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_container_entrypoint.py +16 -26
  3. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_functions.py +3 -1
  4. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_runtime/container_io_manager.py +40 -27
  5. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_runtime/container_io_manager.pyi +13 -11
  6. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/client.pyi +2 -2
  7. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/functions.pyi +6 -6
  8. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal.egg-info/PKG-INFO +1 -1
  9. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal_version/__init__.py +1 -1
  10. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/LICENSE +0 -0
  11. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/README.md +0 -0
  12. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/__init__.py +0 -0
  13. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/__main__.py +0 -0
  14. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_clustered_functions.py +0 -0
  15. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_clustered_functions.pyi +0 -0
  16. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_ipython.py +0 -0
  17. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_location.py +0 -0
  18. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_object.py +0 -0
  19. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_output.py +0 -0
  20. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_partial_function.py +0 -0
  21. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_pty.py +0 -0
  22. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_resolver.py +0 -0
  23. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_resources.py +0 -0
  24. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_runtime/__init__.py +0 -0
  25. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_runtime/asgi.py +0 -0
  26. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_runtime/execution_context.py +0 -0
  27. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_runtime/execution_context.pyi +0 -0
  28. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_runtime/gpu_memory_snapshot.py +0 -0
  29. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_runtime/telemetry.py +0 -0
  30. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_runtime/user_code_imports.py +0 -0
  31. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_serialization.py +0 -0
  32. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_traceback.py +0 -0
  33. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_tunnel.py +0 -0
  34. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_tunnel.pyi +0 -0
  35. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_type_manager.py +0 -0
  36. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_utils/__init__.py +0 -0
  37. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_utils/app_utils.py +0 -0
  38. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_utils/async_utils.py +0 -0
  39. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_utils/blob_utils.py +0 -0
  40. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_utils/bytes_io_segment_payload.py +0 -0
  41. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_utils/deprecation.py +0 -0
  42. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_utils/docker_utils.py +0 -0
  43. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_utils/function_utils.py +0 -0
  44. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_utils/git_utils.py +0 -0
  45. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_utils/grpc_testing.py +0 -0
  46. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_utils/grpc_utils.py +0 -0
  47. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_utils/hash_utils.py +0 -0
  48. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_utils/http_utils.py +0 -0
  49. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_utils/jwt_utils.py +0 -0
  50. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_utils/logger.py +0 -0
  51. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_utils/mount_utils.py +0 -0
  52. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_utils/name_utils.py +0 -0
  53. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_utils/package_utils.py +0 -0
  54. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_utils/pattern_utils.py +0 -0
  55. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_utils/rand_pb_testing.py +0 -0
  56. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_utils/shell_utils.py +0 -0
  57. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_utils/time_utils.py +0 -0
  58. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_vendor/__init__.py +0 -0
  59. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_vendor/a2wsgi_wsgi.py +0 -0
  60. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_vendor/cloudpickle.py +0 -0
  61. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_vendor/tblib.py +0 -0
  62. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/_watcher.py +0 -0
  63. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/app.py +0 -0
  64. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/app.pyi +0 -0
  65. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/call_graph.py +0 -0
  66. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/cli/__init__.py +0 -0
  67. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/cli/_download.py +0 -0
  68. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/cli/_traceback.py +0 -0
  69. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/cli/app.py +0 -0
  70. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/cli/cluster.py +0 -0
  71. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/cli/config.py +0 -0
  72. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/cli/container.py +0 -0
  73. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/cli/dict.py +0 -0
  74. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/cli/entry_point.py +0 -0
  75. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/cli/environment.py +0 -0
  76. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/cli/import_refs.py +0 -0
  77. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/cli/launch.py +0 -0
  78. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/cli/network_file_system.py +0 -0
  79. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/cli/profile.py +0 -0
  80. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/cli/programs/__init__.py +0 -0
  81. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/cli/programs/run_jupyter.py +0 -0
  82. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/cli/programs/vscode.py +0 -0
  83. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/cli/queues.py +0 -0
  84. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/cli/run.py +0 -0
  85. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/cli/secret.py +0 -0
  86. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/cli/token.py +0 -0
  87. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/cli/utils.py +0 -0
  88. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/cli/volume.py +0 -0
  89. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/client.py +0 -0
  90. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/cloud_bucket_mount.py +0 -0
  91. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/cloud_bucket_mount.pyi +0 -0
  92. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/cls.py +0 -0
  93. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/cls.pyi +0 -0
  94. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/config.py +0 -0
  95. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/container_process.py +0 -0
  96. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/container_process.pyi +0 -0
  97. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/dict.py +0 -0
  98. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/dict.pyi +0 -0
  99. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/environments.py +0 -0
  100. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/environments.pyi +0 -0
  101. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/exception.py +0 -0
  102. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/experimental/__init__.py +0 -0
  103. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/experimental/ipython.py +0 -0
  104. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/file_io.py +0 -0
  105. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/file_io.pyi +0 -0
  106. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/file_pattern_matcher.py +0 -0
  107. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/functions.py +0 -0
  108. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/gpu.py +0 -0
  109. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/image.py +0 -0
  110. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/image.pyi +0 -0
  111. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/io_streams.py +0 -0
  112. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/io_streams.pyi +0 -0
  113. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/mount.py +0 -0
  114. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/mount.pyi +0 -0
  115. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/network_file_system.py +0 -0
  116. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/network_file_system.pyi +0 -0
  117. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/object.py +0 -0
  118. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/object.pyi +0 -0
  119. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/output.py +0 -0
  120. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/parallel_map.py +0 -0
  121. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/parallel_map.pyi +0 -0
  122. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/partial_function.py +0 -0
  123. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/partial_function.pyi +0 -0
  124. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/proxy.py +0 -0
  125. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/proxy.pyi +0 -0
  126. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/py.typed +0 -0
  127. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/queue.py +0 -0
  128. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/queue.pyi +0 -0
  129. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/requirements/2023.12.312.txt +0 -0
  130. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/requirements/2023.12.txt +0 -0
  131. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/requirements/2024.04.txt +0 -0
  132. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/requirements/2024.10.txt +0 -0
  133. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/requirements/PREVIEW.txt +0 -0
  134. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/requirements/README.md +0 -0
  135. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/requirements/base-images.json +0 -0
  136. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/retries.py +0 -0
  137. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/runner.py +0 -0
  138. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/runner.pyi +0 -0
  139. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/running_app.py +0 -0
  140. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/sandbox.py +0 -0
  141. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/sandbox.pyi +0 -0
  142. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/schedule.py +0 -0
  143. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/scheduler_placement.py +0 -0
  144. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/secret.py +0 -0
  145. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/secret.pyi +0 -0
  146. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/serving.py +0 -0
  147. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/serving.pyi +0 -0
  148. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/snapshot.py +0 -0
  149. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/snapshot.pyi +0 -0
  150. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/stream_type.py +0 -0
  151. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/token_flow.py +0 -0
  152. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/token_flow.pyi +0 -0
  153. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/volume.py +0 -0
  154. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal/volume.pyi +0 -0
  155. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal.egg-info/SOURCES.txt +0 -0
  156. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal.egg-info/dependency_links.txt +0 -0
  157. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal.egg-info/entry_points.txt +0 -0
  158. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal.egg-info/requires.txt +0 -0
  159. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal.egg-info/top_level.txt +0 -0
  160. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal_docs/__init__.py +0 -0
  161. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal_docs/gen_cli_docs.py +0 -0
  162. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal_docs/gen_reference_docs.py +0 -0
  163. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal_docs/mdmd/__init__.py +0 -0
  164. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal_docs/mdmd/mdmd.py +0 -0
  165. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal_docs/mdmd/signatures.py +0 -0
  166. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal_proto/__init__.py +0 -0
  167. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal_proto/api.proto +0 -0
  168. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal_proto/api_grpc.py +0 -0
  169. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal_proto/api_pb2.py +0 -0
  170. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal_proto/api_pb2.pyi +0 -0
  171. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal_proto/api_pb2_grpc.py +0 -0
  172. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal_proto/api_pb2_grpc.pyi +0 -0
  173. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal_proto/modal_api_grpc.py +0 -0
  174. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal_proto/modal_options_grpc.py +0 -0
  175. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal_proto/options.proto +0 -0
  176. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal_proto/options_grpc.py +0 -0
  177. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal_proto/options_pb2.py +0 -0
  178. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal_proto/options_pb2.pyi +0 -0
  179. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal_proto/options_pb2_grpc.py +0 -0
  180. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal_proto/options_pb2_grpc.pyi +0 -0
  181. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal_proto/py.typed +0 -0
  182. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/modal_version/__main__.py +0 -0
  183. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/pyproject.toml +0 -0
  184. {modal-1.0.6.dev13 → modal-1.0.6.dev15}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: modal
3
- Version: 1.0.6.dev13
3
+ Version: 1.0.6.dev15
4
4
  Summary: Python client library for Modal
5
5
  Author-email: Modal Labs <support@modal.com>
6
6
  License: Apache-2.0
@@ -15,7 +15,6 @@ if telemetry_socket:
15
15
  instrument_imports(telemetry_socket)
16
16
 
17
17
  import asyncio
18
- import concurrent.futures
19
18
  import inspect
20
19
  import queue
21
20
  import signal
@@ -49,7 +48,6 @@ from ._runtime.container_io_manager import (
49
48
  ContainerIOManager,
50
49
  IOContext,
51
50
  UserException,
52
- _ContainerIOManager,
53
51
  )
54
52
 
55
53
  if TYPE_CHECKING:
@@ -198,21 +196,16 @@ def call_function(
198
196
 
199
197
  # Send up to this many outputs at a time.
200
198
  generator_queue: asyncio.Queue[Any] = await container_io_manager._queue_create.aio(1024)
201
- generator_output_task = asyncio.create_task(
202
- container_io_manager.generator_output_task.aio(
203
- function_call_ids[0],
204
- io_context.finalized_function.data_format,
205
- generator_queue,
206
- )
207
- )
208
-
209
- item_count = 0
210
- async for value in res:
211
- await container_io_manager._queue_put.aio(generator_queue, value)
212
- item_count += 1
199
+ async with container_io_manager.generator_output_sender(
200
+ function_call_ids[0],
201
+ io_context.finalized_function.data_format,
202
+ generator_queue,
203
+ ):
204
+ item_count = 0
205
+ async for value in res:
206
+ await container_io_manager._queue_put.aio(generator_queue, value)
207
+ item_count += 1
213
208
 
214
- await container_io_manager._queue_put.aio(generator_queue, _ContainerIOManager._GENERATOR_STOP_SENTINEL)
215
- await generator_output_task # Wait to finish sending generator outputs.
216
209
  message = api_pb2.GeneratorDone(items_total=item_count)
217
210
  await container_io_manager.push_outputs.aio(
218
211
  io_context,
@@ -249,20 +242,17 @@ def call_function(
249
242
 
250
243
  # Send up to this many outputs at a time.
251
244
  generator_queue: asyncio.Queue[Any] = container_io_manager._queue_create(1024)
252
- generator_output_task: concurrent.futures.Future = container_io_manager.generator_output_task( # type: ignore
245
+
246
+ with container_io_manager.generator_output_sender(
253
247
  function_call_ids[0],
254
248
  io_context.finalized_function.data_format,
255
249
  generator_queue,
256
- _future=True, # type: ignore # Synchronicity magic to return a future.
257
- )
258
-
259
- item_count = 0
260
- for value in res:
261
- container_io_manager._queue_put(generator_queue, value)
262
- item_count += 1
250
+ ):
251
+ item_count = 0
252
+ for value in res:
253
+ container_io_manager._queue_put(generator_queue, value)
254
+ item_count += 1
263
255
 
264
- container_io_manager._queue_put(generator_queue, _ContainerIOManager._GENERATOR_STOP_SENTINEL)
265
- generator_output_task.result() # Wait to finish sending generator outputs.
266
256
  message = api_pb2.GeneratorDone(items_total=item_count)
267
257
  container_io_manager.push_outputs(io_context, started_at, message, api_pb2.DATA_FORMAT_GENERATOR_DONE)
268
258
  else:
@@ -451,8 +451,10 @@ class _InputPlaneInvocation:
451
451
  self.attempt_token = retry_response.attempt_token
452
452
  continue
453
453
 
454
+ control_plane_stub = self.client.stub
455
+ # Note: Blob download is done on the control plane stub, not the input plane stub!
454
456
  return await _process_result(
455
- await_response.output.result, await_response.output.data_format, self.stub, self.client
457
+ await_response.output.result, await_response.output.data_format, control_plane_stub, self.client
456
458
  )
457
459
 
458
460
 
@@ -290,7 +290,6 @@ class _ContainerIOManager:
290
290
 
291
291
  _client: _Client
292
292
 
293
- _GENERATOR_STOP_SENTINEL: ClassVar[Sentinel] = Sentinel()
294
293
  _singleton: ClassVar[Optional["_ContainerIOManager"]] = None
295
294
 
296
295
  def _init(self, container_args: api_pb2.ContainerArguments, client: _Client):
@@ -508,33 +507,47 @@ class _ContainerIOManager:
508
507
  req = api_pb2.FunctionCallPutDataRequest(function_call_id=function_call_id, data_chunks=data_chunks)
509
508
  await retry_transient_errors(self._client.stub.FunctionCallPutDataOut, req)
510
509
 
511
- async def generator_output_task(self, function_call_id: str, data_format: int, message_rx: asyncio.Queue) -> None:
512
- """Task that feeds generator outputs into a function call's `data_out` stream."""
513
- index = 1
514
- received_sentinel = False
515
- while not received_sentinel:
516
- message = await message_rx.get()
517
- if message is self._GENERATOR_STOP_SENTINEL:
518
- break
519
- # ASGI 'http.response.start' and 'http.response.body' msgs are observed to be separated by 1ms.
520
- # If we don't sleep here for 1ms we end up with an extra call to .put_data_out().
521
- if index == 1:
522
- await asyncio.sleep(0.001)
523
- serialized_messages = [serialize_data_format(message, data_format)]
524
- total_size = len(serialized_messages[0]) + 512
525
- while total_size < 16 * 1024 * 1024: # 16 MiB, maximum size in a single message
526
- try:
527
- message = message_rx.get_nowait()
528
- except asyncio.QueueEmpty:
529
- break
530
- if message is self._GENERATOR_STOP_SENTINEL:
531
- received_sentinel = True
510
+ @asynccontextmanager
511
+ async def generator_output_sender(
512
+ self, function_call_id: str, data_format: int, message_rx: asyncio.Queue
513
+ ) -> AsyncGenerator[None, None]:
514
+ """Runs background task that feeds generator outputs into a function call's `data_out` stream."""
515
+ GENERATOR_STOP_SENTINEL = Sentinel()
516
+
517
+ async def generator_output_task():
518
+ index = 1
519
+ received_sentinel = False
520
+ while not received_sentinel:
521
+ message = await message_rx.get()
522
+ if message is GENERATOR_STOP_SENTINEL:
532
523
  break
533
- else:
534
- serialized_messages.append(serialize_data_format(message, data_format))
535
- total_size += len(serialized_messages[-1]) + 512 # 512 bytes for estimated framing overhead
536
- await self.put_data_out(function_call_id, index, data_format, serialized_messages)
537
- index += len(serialized_messages)
524
+ # ASGI 'http.response.start' and 'http.response.body' msgs are observed to be separated by 1ms.
525
+ # If we don't sleep here for 1ms we end up with an extra call to .put_data_out().
526
+ if index == 1:
527
+ await asyncio.sleep(0.001)
528
+ serialized_messages = [serialize_data_format(message, data_format)]
529
+ total_size = len(serialized_messages[0]) + 512
530
+ while total_size < 16 * 1024 * 1024: # 16 MiB, maximum size in a single message
531
+ try:
532
+ message = message_rx.get_nowait()
533
+ except asyncio.QueueEmpty:
534
+ break
535
+ if message is GENERATOR_STOP_SENTINEL:
536
+ received_sentinel = True
537
+ break
538
+ else:
539
+ serialized_messages.append(serialize_data_format(message, data_format))
540
+ total_size += len(serialized_messages[-1]) + 512 # 512 bytes for estimated framing overhead
541
+ await self.put_data_out(function_call_id, index, data_format, serialized_messages)
542
+ index += len(serialized_messages)
543
+
544
+ task = asyncio.create_task(generator_output_task())
545
+ try:
546
+ yield
547
+ finally:
548
+ # gracefully stop the task after all current inputs have been sent
549
+ await message_rx.put(GENERATOR_STOP_SENTINEL)
550
+ await task
538
551
 
539
552
  async def _queue_create(self, size: int) -> asyncio.Queue:
540
553
  """Create a queue, on the synchronicity event loop (needed on Python 3.8 and 3.9)."""
@@ -106,7 +106,6 @@ class _ContainerIOManager:
106
106
  _is_interactivity_enabled: bool
107
107
  _fetching_inputs: bool
108
108
  _client: modal.client._Client
109
- _GENERATOR_STOP_SENTINEL: typing.ClassVar[Sentinel]
110
109
  _singleton: typing.ClassVar[typing.Optional[_ContainerIOManager]]
111
110
 
112
111
  def _init(self, container_args: modal_proto.api_pb2.ContainerArguments, client: modal.client._Client): ...
@@ -148,10 +147,10 @@ class _ContainerIOManager:
148
147
  """
149
148
  ...
150
149
 
151
- async def generator_output_task(
150
+ def generator_output_sender(
152
151
  self, function_call_id: str, data_format: int, message_rx: asyncio.queues.Queue
153
- ) -> None:
154
- """Task that feeds generator outputs into a function call's `data_out` stream."""
152
+ ) -> typing.AsyncContextManager[None]:
153
+ """Runs background task that feeds generator outputs into a function call's `data_out` stream."""
155
154
  ...
156
155
 
157
156
  async def _queue_create(self, size: int) -> asyncio.queues.Queue:
@@ -268,7 +267,6 @@ class ContainerIOManager:
268
267
  _is_interactivity_enabled: bool
269
268
  _fetching_inputs: bool
270
269
  _client: modal.client.Client
271
- _GENERATOR_STOP_SENTINEL: typing.ClassVar[Sentinel]
272
270
  _singleton: typing.ClassVar[typing.Optional[ContainerIOManager]]
273
271
 
274
272
  def __init__(self, /, *args, **kwargs):
@@ -367,16 +365,20 @@ class ContainerIOManager:
367
365
 
368
366
  put_data_out: __put_data_out_spec[typing_extensions.Self]
369
367
 
370
- class __generator_output_task_spec(typing_extensions.Protocol[SUPERSELF]):
371
- def __call__(self, /, function_call_id: str, data_format: int, message_rx: asyncio.queues.Queue) -> None:
372
- """Task that feeds generator outputs into a function call's `data_out` stream."""
368
+ class __generator_output_sender_spec(typing_extensions.Protocol[SUPERSELF]):
369
+ def __call__(
370
+ self, /, function_call_id: str, data_format: int, message_rx: asyncio.queues.Queue
371
+ ) -> synchronicity.combined_types.AsyncAndBlockingContextManager[None]:
372
+ """Runs background task that feeds generator outputs into a function call's `data_out` stream."""
373
373
  ...
374
374
 
375
- async def aio(self, /, function_call_id: str, data_format: int, message_rx: asyncio.queues.Queue) -> None:
376
- """Task that feeds generator outputs into a function call's `data_out` stream."""
375
+ def aio(
376
+ self, /, function_call_id: str, data_format: int, message_rx: asyncio.queues.Queue
377
+ ) -> typing.AsyncContextManager[None]:
378
+ """Runs background task that feeds generator outputs into a function call's `data_out` stream."""
377
379
  ...
378
380
 
379
- generator_output_task: __generator_output_task_spec[typing_extensions.Self]
381
+ generator_output_sender: __generator_output_sender_spec[typing_extensions.Self]
380
382
 
381
383
  class ___queue_create_spec(typing_extensions.Protocol[SUPERSELF]):
382
384
  def __call__(self, /, size: int) -> asyncio.queues.Queue:
@@ -31,7 +31,7 @@ class _Client:
31
31
  server_url: str,
32
32
  client_type: int,
33
33
  credentials: typing.Optional[tuple[str, str]],
34
- version: str = "1.0.6.dev13",
34
+ version: str = "1.0.6.dev15",
35
35
  ):
36
36
  """mdmd:hidden
37
37
  The Modal client object is not intended to be instantiated directly by users.
@@ -160,7 +160,7 @@ class Client:
160
160
  server_url: str,
161
161
  client_type: int,
162
162
  credentials: typing.Optional[tuple[str, str]],
163
- version: str = "1.0.6.dev13",
163
+ version: str = "1.0.6.dev15",
164
164
  ):
165
165
  """mdmd:hidden
166
166
  The Modal client object is not intended to be instantiated directly by users.
@@ -428,7 +428,7 @@ class Function(
428
428
 
429
429
  _call_generator: ___call_generator_spec[typing_extensions.Self]
430
430
 
431
- class __remote_spec(typing_extensions.Protocol[P_INNER, ReturnType_INNER, SUPERSELF]):
431
+ class __remote_spec(typing_extensions.Protocol[ReturnType_INNER, P_INNER, SUPERSELF]):
432
432
  def __call__(self, /, *args: P_INNER.args, **kwargs: P_INNER.kwargs) -> ReturnType_INNER:
433
433
  """Calls the function remotely, executing it with the given arguments and returning the execution's result."""
434
434
  ...
@@ -437,7 +437,7 @@ class Function(
437
437
  """Calls the function remotely, executing it with the given arguments and returning the execution's result."""
438
438
  ...
439
439
 
440
- remote: __remote_spec[modal._functions.P, modal._functions.ReturnType, typing_extensions.Self]
440
+ remote: __remote_spec[modal._functions.ReturnType, modal._functions.P, typing_extensions.Self]
441
441
 
442
442
  class __remote_gen_spec(typing_extensions.Protocol[SUPERSELF]):
443
443
  def __call__(self, /, *args, **kwargs) -> typing.Generator[typing.Any, None, None]:
@@ -464,7 +464,7 @@ class Function(
464
464
  """
465
465
  ...
466
466
 
467
- class ___experimental_spawn_spec(typing_extensions.Protocol[P_INNER, ReturnType_INNER, SUPERSELF]):
467
+ class ___experimental_spawn_spec(typing_extensions.Protocol[ReturnType_INNER, P_INNER, SUPERSELF]):
468
468
  def __call__(self, /, *args: P_INNER.args, **kwargs: P_INNER.kwargs) -> FunctionCall[ReturnType_INNER]:
469
469
  """[Experimental] Calls the function with the given arguments, without waiting for the results.
470
470
 
@@ -488,7 +488,7 @@ class Function(
488
488
  ...
489
489
 
490
490
  _experimental_spawn: ___experimental_spawn_spec[
491
- modal._functions.P, modal._functions.ReturnType, typing_extensions.Self
491
+ modal._functions.ReturnType, modal._functions.P, typing_extensions.Self
492
492
  ]
493
493
 
494
494
  class ___spawn_map_inner_spec(typing_extensions.Protocol[P_INNER, SUPERSELF]):
@@ -497,7 +497,7 @@ class Function(
497
497
 
498
498
  _spawn_map_inner: ___spawn_map_inner_spec[modal._functions.P, typing_extensions.Self]
499
499
 
500
- class __spawn_spec(typing_extensions.Protocol[P_INNER, ReturnType_INNER, SUPERSELF]):
500
+ class __spawn_spec(typing_extensions.Protocol[ReturnType_INNER, P_INNER, SUPERSELF]):
501
501
  def __call__(self, /, *args: P_INNER.args, **kwargs: P_INNER.kwargs) -> FunctionCall[ReturnType_INNER]:
502
502
  """Calls the function with the given arguments, without waiting for the results.
503
503
 
@@ -518,7 +518,7 @@ class Function(
518
518
  """
519
519
  ...
520
520
 
521
- spawn: __spawn_spec[modal._functions.P, modal._functions.ReturnType, typing_extensions.Self]
521
+ spawn: __spawn_spec[modal._functions.ReturnType, modal._functions.P, typing_extensions.Self]
522
522
 
523
523
  def get_raw_f(self) -> collections.abc.Callable[..., typing.Any]:
524
524
  """Return the inner Python object wrapped by this Modal Function."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: modal
3
- Version: 1.0.6.dev13
3
+ Version: 1.0.6.dev15
4
4
  Summary: Python client library for Modal
5
5
  Author-email: Modal Labs <support@modal.com>
6
6
  License: Apache-2.0
@@ -1,4 +1,4 @@
1
1
  # Copyright Modal Labs 2025
2
2
  """Supplies the current version of the modal client library."""
3
3
 
4
- __version__ = "1.0.6.dev13"
4
+ __version__ = "1.0.6.dev15"
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
File without changes
File without changes
File without changes
File without changes