nucleus.async_utils¶
A context handler for file form data that handles closing all files in a request. |
- class nucleus.async_utils.FormDataContextHandler(form_data_and_file_pointers_fn)¶
A context handler for file form data that handles closing all files in a request.
Why do I need to wrap my requests in such a funny way?
- Form data must be regenerated on each request to avoid errors
Files must be properly open/closed for each request.
- We need to be able to do 1/2 above multiple times so that we can implement retries
properly.
Write a function that returns a tuple of form data and file pointers, then pass it to the constructor of this class, and this class will handle the rest for you.
- Parameters:
form_data_and_file_pointers_fn (Callable[Ellipsis, Tuple[FileFormData, Sequence[BinaryIO]]])