Mark a thread as more important than other threads (with respect to `sleep`)?

I started using the following code pattern:

my_tasks = []
for i in my_inputs
    task = @spawn my_function(i)
    push!(my_tasks, task)

while !all(istaskdone.(my_tasks))
    println("some progress message about the tasks")

However, if I spawn a lot of tasks, the main thread does not resume from the sleep call, instead it waits for most of the other spawned tasks to finish.

What would be the “proper” way to ensure that the main thread is of sufficiently high priority to continue executing no matter how many tasks were spawned.

You could use some magic to keep a single PARTR thread isolated for just your main task. Doing ccall( :jl_set_task_tid, ...) appropriately and then setting task.sticky = true for each task would do it, although you’d end up needing to manually schedule each task (making the PARTR scheduler mostly useless). This is the case because you can only say what thread a task must run on, but you can’t say which thread a task cannot run on, so if you didn’t manually schedule the non-main tasks, they’d still get placed on the main task’s thread.