MCPcopy Create free account
hub / github.com/dask/dask / fire_tasks

Function fire_tasks

dask/local.py:490–533  ·  view source on GitHub ↗

Fire off a task to the thread pool

(chunksize)

Source from the content-addressed store, hash-verified

488 raise ValueError("Found no accessible jobs in dask")
489
490 def fire_tasks(chunksize):
491 """Fire off a task to the thread pool"""
492 # Determine chunksize and/or number of tasks to submit
493 nready = len(state["ready"])
494 if chunksize == -1:
495 ntasks = nready
496 chunksize = -(ntasks // -num_workers)
497 else:
498 used_workers = -(len(state["running"]) // -chunksize)
499 avail_workers = max(num_workers - used_workers, 0)
500 ntasks = min(nready, chunksize * avail_workers)
501
502 # Prep all ready tasks for submission
503 args = []
504 for _ in range(ntasks):
505 # Get the next task to compute (most recently added)
506 key = state["ready"].pop()
507 # Notify task is running
508 state["running"].add(key)
509 for f in pretask_cbs:
510 f(key, dsk, state)
511
512 # Prep args to send
513 data = {
514 dep: state["cache"][dep] for dep in state["dependencies"][key]
515 }
516 args.append(
517 (
518 key,
519 dumps((dsk[key], data)),
520 dumps,
521 loads,
522 get_id,
523 pack_exception,
524 )
525 )
526
527 # Batch submit
528 for i in range(-(len(args) // -chunksize)):
529 each_args = args[i * chunksize : (i + 1) * chunksize]
530 if not each_args:
531 break
532 fut = submit(batch_execute_tasks, each_args)
533 fut.add_done_callback(queue.put)
534
535 # Main loop, wait on tasks to finish, insert new ones
536 while state["waiting"] or state["ready"] or state["running"]:

Callers 1

get_asyncFunction · 0.85

Calls 5

maxFunction · 0.85
minFunction · 0.85
popMethod · 0.80
fFunction · 0.50
addMethod · 0.45

Tested by

no test coverage detected