A message-delivery framework supports early termination: it stops examining a batch once two records have been delivered. Its controlling method is shown below. Each method call returns normally, accept has no side effects, and there are no retries.
def run_batches(self, batches): for batch in batches: delivered = 0 for record in batch: if self.accept(record): self.deliver(record) delivered += 1 if delivered == 2: break
The potential accept outcomes in original record order are:
An outcome is produced only if its record is actually examined. All three batches are supplied to run_batches in the listed order.
How many calls to accept occur across the complete execution? Answer in calls, as an exact whole number.
Unlock full course notes by signing up
Cost of framework-managed exports
A hypothetical image-export framework uses two hook methods, application-supplied operations invoked by its controlling method. It calls eligible once for each of 18 images and calls export once for each image that qualifies. Exactly 11 images qualify. Every call returns normally, with no retries or early stopping.
Each eligible call takes 0.10 ms, each export call takes 0.80 ms, and all remaining framework work takes 1.50 ms in total. Execution is sequential, and these timings include all relevant work without overlap.
Find the number of eligible calls and the number of export calls, each as an exact whole number of calls. Also find the total execution time in ms, to one decimal place.
Customize behavior while preserving the workflow
A reporting framework provides run, which validates a session, invokes a registered exporter's write method, and records completion after a normal return. Validation and completion recording are required for every report. The documentation identifies write as the supported customization point and directs applications to use run as the report entry point.
Which changes follow the documented extension mechanism and preserve the required workflow? Select all that apply. Assume every described write implementation returns normally.
Count objects across framework lifetimes
An image-processing framework manages application objects during one run. It opens sessions A, B, and C in that order, finishing all jobs in one session before opening the next. Their workloads are:
The framework applies these object-management rules:
It constructs one CodecRegistry at startup and retains it until shutdown.