Killing long-running thread starting in a web server

I’m trying to use Oxygen.jl as an API for a long running ccall. I’m trying to create a toy example where, after 30 seconds, the solver task called by call_solver() on a new thread is passed InterruptException and stops. The way I’m attempting this is having a polling function called check_solver() on a separate thread which schedules the exception after 30 seconds.

    function check_solver(t)  
      time = 0
      timeout = 30
      while time < timeout
        sleep(1)
        time +=1 
        println("Current time is $time")
      end
        schedule(t,InterruptException();error = true)
    end

    t = Threads.@spawn call_solver()
    wait(Threads.@spawn check_solver(t))

this doesn’t appear to work on the ccall runs to completion. I’ve also tried something simple like:

  t = Threads.@spawn call_solver()
  sleep(10)
  schedule(t,InterruptException();error = true)

and this also doesn’t work. I have a feeling that either the ccall switches threads on interruption or the schedule never gets called as the ccall is continually using the thread.

Thanks for your help, I’m a bit stumped!

I’ve tried watching htop during the execution and I’ve noticed that before running schedule(t,InterruptException();error = true) I can see it’s only running on a single thread:

but after running schedule(t,InterruptException();error = true) multiple times I can see that the other threads start seeing increased loads: