Asynchronous Programming and "Threads.@threads for" with limited number of threads

Hi,
I hope I selected the right topic for my question.
Please tell me if I did something wrong as it is my first time posting here.
It seems as I am not able to use the @ symbol so I replaced it with [at].

I am working on a responsive Rest-API that uses Julia.
One of the tasks of the API is to compute on larger scale data.
Because of this “Threads.[at] threads for” is being used at one point in the code.
Since the API should remain responsive during this computation I worked with [at]async to invoke the
computation task. This lets the function that calls the computation return. However, all other calls to the API are being blocked. This is most likely because “Threads.[at]threads for” makes use of all available threads. Using [at]spawn instead of [at]async to call the computation task lets the API stay responsive. However, the computation is not being computed in parallel. Most likely because [at]spawn assigns the following computations to a random thread.

I have seen that there is a macro for “Threads.[at]threads for” however only the static value seems to be supported at this point in time.

Has someone already encountered a similar problem or maybe knows an alternative solution?
I think executing “Threads.[at]threads for” for only a specified number of threads might be the best solution but I do not think it is possible if I read the documentation correctly.

Kind regards,
Anton

I’ve edited your title to fix that. In the body of your message you can use backticks

`@threads`
1 Like

Thank you!