Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flush parameter to captured_request() #1058

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion examples/request_context_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
with Picamera2() as picam2:
picam2.start()

for _ in range(50):
for _ in range(25):
with picam2.captured_request() as request:
print(request)
with picam2.captured_request(flush=True) as request:
print(request)
4 changes: 2 additions & 2 deletions picamera2/picamera2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1478,9 +1478,9 @@ def capture_request_and_stop_(self):
return self.dispatch_functions(functions, wait, signal_function, immediate=True)

@contextlib.contextmanager
def captured_request(self):
def captured_request(self, flush=None):
"""Capture a completed request using the context manager which guarantees its release."""
request = self.capture_request()
request = self.capture_request(flush=flush)
try:
yield request
finally:
Expand Down
Loading