Given the current state of a Loader instance, perform a batch load from its current queue.
(loader)
| 193 | |
| 194 | |
| 195 | def dispatch_queue(loader): |
| 196 | """ |
| 197 | Given the current state of a Loader instance, perform a batch load |
| 198 | from its current queue. |
| 199 | """ |
| 200 | # Take the current loader queue, replacing it with an empty queue. |
| 201 | queue = loader._queue |
| 202 | loader._queue = [] |
| 203 | |
| 204 | # If a max_batch_size was provided and the queue is longer, then segment the |
| 205 | # queue into multiple batches, otherwise treat the queue as a single batch. |
| 206 | max_batch_size = loader.max_batch_size |
| 207 | |
| 208 | if max_batch_size and max_batch_size < len(queue): |
| 209 | chunks = get_chunks(queue, max_batch_size) |
| 210 | for chunk in chunks: |
| 211 | ensure_future(dispatch_queue_batch(loader, chunk)) |
| 212 | else: |
| 213 | ensure_future(dispatch_queue_batch(loader, queue)) |
| 214 | |
| 215 | |
| 216 | async def dispatch_queue_batch(loader, queue): |
no test coverage detected