# \#async

**URL:** https://discourse.julialang.org/tag/async/1233.md

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

---

## [How to write a master-subproblem iterative algorithm asynchronously?](https://discourse.julialang.org/t/how-to-write-a-master-subproblem-iterative-algorithm-asynchronously/131853)

<div class="topic-metadata">

**Author:** [@WalterMadelim](https://discourse.julialang.org/u/WalterMadelim)\
**Replies:** 36\
**Last updated:** [November 29, 2025, 12:03pm UTC](https://discourse.julialang.org/t/how-to-write-a-master-subproblem-iterative-algorithm-asynchronously/131853 "2025-11-29T12:03:10Z")

</div>

My question is inspired by an optimization problem, e.g. the famous Benders decomposition. But I’ll introduce it here in an abstract easily-comprehended fashion. Settings of the problem :blue\_circle: On one hand, there …

---

## [Will Julia exits only after all threads get their tasks done?](https://discourse.julialang.org/t/will-julia-exits-only-after-all-threads-get-their-tasks-done/133744)

<div class="topic-metadata">

**Author:** [@WalterMadelim](https://discourse.julialang.org/u/WalterMadelim)\
**Replies:** 4\
**Last updated:** [November 9, 2025, 3:58pm UTC](https://discourse.julialang.org/t/will-julia-exits-only-after-all-threads-get-their-tasks-done/133744 "2025-11-09T15:58:26Z")

</div>

From this link Can the threads in the :interactive pool also undertake heavy computing tasks? - #9 by WalterMadelim I find that this behavior is puzzling: Define this file s.jl function bzwt(t) tdue = time\_ns(…

---

## [Can the threads in the :interactive pool also undertake heavy computing tasks?](https://discourse.julialang.org/t/can-the-threads-in-the-interactive-pool-also-undertake-heavy-computing-tasks/133725)

<div class="topic-metadata">

**Author:** [@WalterMadelim](https://discourse.julialang.org/u/WalterMadelim)\
**Replies:** 7\
**Last updated:** [November 8, 2025, 1:15am UTC](https://discourse.julialang.org/t/can-the-threads-in-the-interactive-pool-also-undertake-heavy-computing-tasks/133725 "2025-11-08T01:15:17Z")

</div>

(From a related issue Unsticky Tasks stick to threadpool since 1.10, causing issues since 1.12 · Issue #59936 · JuliaLang/julia · GitHub But here I’m not referring to the functional API Task, instead, I’m talking about @…

---

## [Is the scheduler's queue ordered?](https://discourse.julialang.org/t/is-the-schedulers-queue-ordered/133414)

<div class="topic-metadata">

**Author:** [@WalterMadelim](https://discourse.julialang.org/u/WalterMadelim)\
**Replies:** 0\
**Last updated:** [October 24, 2025, 10:20am UTC](https://discourse.julialang.org/t/is-the-schedulers-queue-ordered/133414 "2025-10-24T10:20:18Z")

</div>

I spawn 5 tasks in sequence 1 to 5 (I assume the function foreach is strictly ordered). If I start julia with 1 default thread, it is ordered: ❯ julia --threads=1,1 \_ \_ \_ \_(\_)\_ | Documentat…

---

## [Is the operation scheduling a task blocking?](https://discourse.julialang.org/t/is-the-operation-scheduling-a-task-blocking/133372)

<div class="topic-metadata">

**Author:** [@WalterMadelim](https://discourse.julialang.org/u/WalterMadelim)\
**Replies:** 11\
**Last updated:** [October 23, 2025, 1:16pm UTC](https://discourse.julialang.org/t/is-the-operation-scheduling-a-task-blocking/133372 "2025-10-23T13:16:00Z")

</div>

Here is the doc Asynchronous Programming · The Julia Language It is common to want to create a task and schedule it right away, so the macro Threads.@spawn is provided for that purpose –- Threads.@spawn x is equivalent…

---

## [The same async program run on (Linux+AMD) vs (Win+Intel), over 6x performance difference](https://discourse.julialang.org/t/the-same-async-program-run-on-linux-amd-vs-win-intel-over-6x-performance-difference/133276)

<div class="topic-metadata">

**Author:** [@WalterMadelim](https://discourse.julialang.org/u/WalterMadelim)\
**Replies:** 5\
**Last updated:** [October 23, 2025, 9:38am UTC](https://discourse.julialang.org/t/the-same-async-program-run-on-linux-amd-vs-win-intel-over-6x-performance-difference/133276 "2025-10-23T09:38:33Z")

</div>

Long story short: I wrote a async programming code which uses multithreads. The same code is run on two servers. The Linux server is 6.5 times faster than the other (both attaining the same correct results). I’m not hur…

---

## [Can you find where this asynchronous program get stuck at?](https://discourse.julialang.org/t/can-you-find-where-this-asynchronous-program-get-stuck-at/131907)

<div class="topic-metadata">

**Author:** [@WalterMadelim](https://discourse.julialang.org/u/WalterMadelim)\
**Replies:** 2\
**Last updated:** [August 28, 2025, 9:45am UTC](https://discourse.julialang.org/t/can-you-find-where-this-asynchronous-program-get-stuck-at/131907 "2025-08-28T09:45:13Z")

</div>

I wrote a weird test function function test() function taskbody(k, x, j, e) sleep(0.5 \* j) println("At k = $k, j = $j, x = $x") @lock mylock i+=1 notify(e) end my\_lock = Threa…

---

## [Close instead of wait if TCP socket is never drained](https://discourse.julialang.org/t/close-instead-of-wait-if-tcp-socket-is-never-drained/131727)

<div class="topic-metadata">

**Author:** [@ettersi](https://discourse.julialang.org/u/ettersi)\
**Replies:** 1\
**Last updated:** [August 24, 2025, 3:23pm UTC](https://discourse.julialang.org/t/close-instead-of-wait-if-tcp-socket-is-never-drained/131727 "2025-08-24T15:23:50Z")

</div>

I was wondering how the triplet of OS, libuv and Julia handles the scenario where a TCP socket is constantly written to but never read from on the peer’s side, so I came up with this little test script. s = listen(1234)…

---

## [Seeking advice on asynchronous programming problem](https://discourse.julialang.org/t/seeking-advice-on-asynchronous-programming-problem/131464)

<div class="topic-metadata">

**Author:** [@benninkrs](https://discourse.julialang.org/u/benninkrs)\
**Replies:** 4\
**Last updated:** [August 10, 2025, 5:38am UTC](https://discourse.julialang.org/t/seeking-advice-on-asynchronous-programming-problem/131464 "2025-08-10T05:38:00Z")

</div>

I’m new to asynchronous programming and have a use case that I’m not sure how to express in terms of Julia concepts. I’d greatly appreciate any suggestions others may have to offer. I have a task A, that consists of con…

---

## [Concurrent Downloads.curl usage results in Error: curl\_multi\_socket\_action: 8](https://discourse.julialang.org/t/concurrent-downloads-curl-usage-results-in-error-curl-multi-socket-action-8/129860)

<div class="topic-metadata">

**Author:** [@csvance](https://discourse.julialang.org/u/csvance)\
**Replies:** 0\
**Last updated:** [June 13, 2025, 12:54pm UTC](https://discourse.julialang.org/t/concurrent-downloads-curl-usage-results-in-error-curl-multi-socket-action-8/129860 "2025-06-13T12:54:33Z")

</div>

Hi everyone, new to Julia and looking to integrate it into a SaMD as an alternative to Numba for performance critical sections of the code. As part of the performance critical sections, I’m trying to to use gRPC to call…

---

## [Compiling with @async](https://discourse.julialang.org/t/compiling-with-async/129726)

<div class="topic-metadata">

**Author:** [@Doug719](https://discourse.julialang.org/u/Doug719)\
**Replies:** 1\
**Last updated:** [June 7, 2025, 6:25pm UTC](https://discourse.julialang.org/t/compiling-with-async/129726 "2025-06-07T18:25:36Z")

</div>

If I enter t1 = @async begin; sleep(5); println("done1"); end at the julia REPL, I get Task (runnable, started) @0x00007f575a6c3d00 julia\> done1 If I compile and run function main() t1 = @async begin; sleep…

---

## [Fetching the latest value from external sources using Channel](https://discourse.julialang.org/t/fetching-the-latest-value-from-external-sources-using-channel/126901)

<div class="topic-metadata">

**Author:** [@leejm516](https://discourse.julialang.org/u/leejm516)\
**Replies:** 0\
**Last updated:** [March 13, 2025, 9:54am UTC](https://discourse.julialang.org/t/fetching-the-latest-value-from-external-sources-using-channel/126901 "2025-03-13T09:54:14Z")

</div>

Hi! Sorry for my bad English to describe the title. I am trying to make a small code which fetches a value from a MCU (Arduino, ESP32, etc.) upon request. The MCU periodically saves the sensor value measured into its …

---

## [Task termination](https://discourse.julialang.org/t/task-termination/25231)

<div class="topic-metadata">

**Author:** [@tomhaber](https://discourse.julialang.org/u/tomhaber)\
**Replies:** 7\
**Last updated:** [December 9, 2024, 1:53pm UTC](https://discourse.julialang.org/t/task-termination/25231 "2024-12-09T13:53:23Z")

</div>

I’m trying to get the following to work (or something like it) function execute(f::Function) exec = Executor() t = schedule(@task try while true run!(exec) yield() …

---

## [How to achieve Non blocking IO with Julia](https://discourse.julialang.org/t/how-to-achieve-non-blocking-io-with-julia/117503)

<div class="topic-metadata">

**Author:** [@Chamika\_Kasun](https://discourse.julialang.org/u/Chamika_Kasun)\
**Replies:** 3\
**Last updated:** [July 29, 2024, 6:48am UTC](https://discourse.julialang.org/t/how-to-achieve-non-blocking-io-with-julia/117503 "2024-07-29T06:48:23Z")

</div>

I have a function that is executed through a Julia thread. In this function, there is a execute\_psql\_string\_await function that performs a PostgreSQL stored procedure call using the LibPQ library. Currently, while this q…

---

## [Does PythonCall block all \`@async\` routines?](https://discourse.julialang.org/t/does-pythoncall-block-all-async-routines/114722)

<div class="topic-metadata">

**Author:** [@aryavorskiy](https://discourse.julialang.org/u/aryavorskiy)\
**Replies:** 2\
**Last updated:** [May 25, 2024, 5:05pm UTC](https://discourse.julialang.org/t/does-pythoncall-block-all-async-routines/114722 "2024-05-25T17:05:14Z")

</div>

I am trying to write a simple timing function. To avoid waiting for too long, I made it stop waiting and return Inf at some point. I achieved it this way: function time\_function(f, input...; maxtime=1) c = Channel{F…

---

## [\[ANN\] Asynchronous Workflow Using Julia Tutorial](https://discourse.julialang.org/t/ann-asynchronous-workflow-using-julia-tutorial/92756)

<div class="topic-metadata">

**Author:** [@TheCedarPrince](https://discourse.julialang.org/u/TheCedarPrince)\
**Replies:** 1\
**Last updated:** [April 13, 2024, 7:36pm UTC](https://discourse.julialang.org/t/ann-asynchronous-workflow-using-julia-tutorial/92756 "2024-04-13T19:36:58Z")

</div>

Hi folks :wave: I recently wrote a blog post on an asynchronous workflow within Julia that can be used for data science, literate programming, and other sorts of work flows. I was inspired by a discussion here: Franklin…

---

## [How does io redirection work with tasks?](https://discourse.julialang.org/t/how-does-io-redirection-work-with-tasks/112405)

<div class="topic-metadata">

**Author:** [@jules](https://discourse.julialang.org/u/jules)\
**Replies:** 2\
**Last updated:** [April 2, 2024, 11:56pm UTC](https://discourse.julialang.org/t/how-does-io-redirection-work-with-tasks/112405 "2024-04-02T23:56:28Z")

</div>

I don’t understand this simple MWE: julia\> redirect\_stdio(;stdout = devnull) do @async println("hello") @async redirect\_io(; stdout = devnull) do println("hey") end …

---

## [Handling concurrent writes to websocket](https://discourse.julialang.org/t/handling-concurrent-writes-to-websocket/109843)

<div class="topic-metadata">

**Author:** [@hhaensel](https://discourse.julialang.org/u/hhaensel)\
**Replies:** 0\
**Last updated:** [February 6, 2024, 11:16pm UTC](https://discourse.julialang.org/t/handling-concurrent-writes-to-websocket/109843 "2024-02-06T23:16:46Z")

</div>

We have a server handling websocket connections that can be written to by async tasks. It turns out that a simple Socket.send(ws, msg) is not protecting against concurrent use. I came up with a message queue that uses C…

---

## [Race condition reading from Pipe](https://discourse.julialang.org/t/race-condition-reading-from-pipe/108707)

<div class="topic-metadata">

**Author:** [@goerz](https://discourse.julialang.org/u/goerz)\
**Replies:** 1\
**Last updated:** [January 11, 2024, 11:10pm UTC](https://discourse.julialang.org/t/race-condition-reading-from-pipe/108707 "2024-01-11T23:10:24Z")

</div>

Splitting this off from A \`tee\` option for \`IOCapture\` Does the following minimal working example for asynchronously reading data from a Pipe involve a race condition? using Random function main() pipe = Pipe() …

---

## [Base.throwto() blocking perpetually](https://discourse.julialang.org/t/base-throwto-blocking-perpetually/108237)

<div class="topic-metadata">

**Author:** [@JoO0oss](https://discourse.julialang.org/u/JoO0oss)\
**Replies:** 1\
**Last updated:** [January 1, 2024, 10:00pm UTC](https://discourse.julialang.org/t/base-throwto-blocking-perpetually/108237 "2024-01-01T22:00:44Z")

</div>

I recently found that throwto() never returns, it just hangs (see this GitHub issue) and constructed a little demo: task = @async begin while true print("-") end end sleep(0.003) println("Throwing...")…

---

## [Override DocStringExtension @template](https://discourse.julialang.org/t/override-docstringextension-template/106954)

<div class="topic-metadata">

**Author:** [@jlbosse](https://discourse.julialang.org/u/jlbosse)\
**Replies:** 0\
**Last updated:** [November 30, 2023, 1:59pm UTC](https://discourse.julialang.org/t/override-docstringextension-template/106954 "2023-11-30T13:59:21Z")

</div>

DocStringExtensions provides the @template macro that allows one to automatically interpolate the function signatures into their docstring without having to write them out or add $SIGNATURES into the docstring. Is there…

---

## [Is there a possibility to prevent task switches in a block of code?](https://discourse.julialang.org/t/is-there-a-possibility-to-prevent-task-switches-in-a-block-of-code/106798)

<div class="topic-metadata">

**Author:** [@schlichtanders](https://discourse.julialang.org/u/schlichtanders)\
**Replies:** 49\
**Last updated:** [November 27, 2023, 3:54pm UTC](https://discourse.julialang.org/t/is-there-a-possibility-to-prevent-task-switches-in-a-block-of-code/106798 "2023-11-27T15:54:16Z")

</div>

I would like to ensure that within a certain block of code no task switch can happen. A bit like an “atomic block” for async tasks

---

## [How to write an asynchronous version of the following code?](https://discourse.julialang.org/t/how-to-write-an-asynchronous-version-of-the-following-code/104657)

<div class="topic-metadata">

**Author:** [@Xiaoguang\_Pan](https://discourse.julialang.org/u/Xiaoguang_Pan)\
**Replies:** 4\
**Last updated:** [October 6, 2023, 4:54pm UTC](https://discourse.julialang.org/t/how-to-write-an-asynchronous-version-of-the-following-code/104657 "2023-10-06T16:54:38Z")

</div>

function parseFiles(inputFile::String,outFile::String) outf = open(outFile,"w") ### read in and process for line in eachline(inputFile) if startswith(line,"#") continue else …

---

## [Interrupts in @async code](https://discourse.julialang.org/t/interrupts-in-async-code/95837)

<div class="topic-metadata">

**Author:** [@ettersi](https://discourse.julialang.org/u/ettersi)\
**Replies:** 20\
**Last updated:** [July 19, 2023, 4:16pm UTC](https://discourse.julialang.org/t/interrupts-in-async-code/95837 "2023-07-19T16:16:08Z")

</div>

I’m trying to wrap my head around how Julia handles interrupts in @async code. I have three different scripts that I’m trying to interrupt using ctrl+c, with various degrees of success. Script1: julia\> @async begin …

---

## [Iterating through an inner loop with @async](https://discourse.julialang.org/t/iterating-through-an-inner-loop-with-async/100954)

<div class="topic-metadata">

**Author:** [@phantom](https://discourse.julialang.org/u/phantom)\
**Replies:** 8\
**Last updated:** [June 30, 2023, 11:01am UTC](https://discourse.julialang.org/t/iterating-through-an-inner-loop-with-async/100954 "2023-06-30T11:01:37Z")

</div>

Suppose I have the following function stoptest where I am able to stop the function from outside the loop by setting a Ref() object = false. The return variable should equal to the value of the variable in the println w…

---

## [Return the ith iteration value of a variable in a for loop when the broken from the outside using @async](https://discourse.julialang.org/t/return-the-ith-iteration-value-of-a-variable-in-a-for-loop-when-the-broken-from-the-outside-using-async/100301)

<div class="topic-metadata">

**Author:** [@phantom](https://discourse.julialang.org/u/phantom)\
**Replies:** 7\
**Last updated:** [June 15, 2023, 1:10am UTC](https://discourse.julialang.org/t/return-the-ith-iteration-value-of-a-variable-in-a-for-loop-when-the-broken-from-the-outside-using-async/100301 "2023-06-15T01:10:13Z")

</div>

Hi sorry if I am being dense here. I would like the option of terminating a for loop from outside the function. If the loop is completed it should return the value of the variable being modified. However if the loop …

---

## [How does Julia Async Task Scheduler work?](https://discourse.julialang.org/t/how-does-julia-async-task-scheduler-work/96675)

<div class="topic-metadata">

**Author:** [@defect](https://discourse.julialang.org/u/defect)\
**Replies:** 3\
**Last updated:** [March 27, 2023, 11:26pm UTC](https://discourse.julialang.org/t/how-does-julia-async-task-scheduler-work/96675 "2023-03-27T23:26:45Z")

</div>

I want to understand how the Julia task scheduler works. Like I get how the Python asyncio async mechanism works, but I find myself unable to find anything about that topic in julia. I know you don’t have to annotate th…

---

## [Best Way to Break out of Recursive Loop in Julia](https://discourse.julialang.org/t/best-way-to-break-out-of-recursive-loop-in-julia/95653)

<div class="topic-metadata">

**Author:** [@phantom](https://discourse.julialang.org/u/phantom)\
**Replies:** 4\
**Last updated:** [March 8, 2023, 10:07am UTC](https://discourse.julialang.org/t/best-way-to-break-out-of-recursive-loop-in-julia/95653 "2023-03-08T10:07:07Z")

</div>

This is probably not a great example of recursion but suppose I have a recursive function, usually in a loop I can break out of the first layer with something simple like function check(stuff) cont = Ref(true) @…

---

## [Best way to break out of recursive loop in Julia?](https://discourse.julialang.org/t/best-way-to-break-out-of-recursive-loop-in-julia/95652)

<div class="topic-metadata">

**Author:** [@phantom](https://discourse.julialang.org/u/phantom)\
**Replies:** 0\
**Last updated:** [March 7, 2023, 8:22am UTC](https://discourse.julialang.org/t/best-way-to-break-out-of-recursive-loop-in-julia/95652 "2023-03-07T08:22:14Z")

</div>

(topic deleted by author)

---

## [Nested async testsets](https://discourse.julialang.org/t/nested-async-testsets/95367)

<div class="topic-metadata">

**Author:** [@ettersi](https://discourse.julialang.org/u/ettersi)\
**Replies:** 4\
**Last updated:** [March 4, 2023, 1:38pm UTC](https://discourse.julialang.org/t/nested-async-testsets/95367 "2023-03-04T13:38:04Z")

</div>

Documenting this mostly for myself, but may be useful for others as well. Julia currently does not handle nested asynchronous test sets correctly. julia\> @testset verbose=true "foo" begin @sync @async @test…

[Next page](https://discourse.julialang.org/tag/async/1233.md?match_all_tags=true&page=1&tags%5B%5D=async)
