# Debugging Threads.@spawn applied to Expr data

**URL:** <https://discourse.julialang.org/t/debugging-threads-spawn-applied-to-expr-data/61359>\
**Category:** General Usage\
**Tags:** metaprogramming, multithreading, debugging\
**Created:** [May 18, 2021, 1:29pm UTC](https://discourse.julialang.org/t/debugging-threads-spawn-applied-to-expr-data/61359 "2021-05-18T13:29:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ericsfraga](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ericsfraga/32/192_2.png) [@ericsfraga](https://discourse.julialang.org/u/ericsfraga)\
**Post date:** [May 18, 2021, 1:29pm UTC](https://discourse.julialang.org/t/debugging-threads-spawn-applied-to-expr-data/61359/1 "2021-05-18T13:29:39Z")

</div>

I am using meta-programming combined with multi-threading. I am trying to `@spawn` an `Expr` expression which is evaluated, i.e.

```julia
e = quote [...] end
tmp = Threads.@spawn eval(e)

```

If I `@show tmp`, sometimes it says `Task (runnable)` and other times `Task (failed)`. In either case, the task doesn’t actually do anything, or I cannot figure out what it is doing: complete silence, i.e. no output etc… Are there any tools for debugging such a statement?

(I will be converting this statement to spawning a function call and do the expression evaluation inside that function next but I would prefer to avoid doing this.)

Thank you.

---

<div class="post-metadata">

**Author:** ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)\
**Post date:** [May 18, 2021, 2:40pm UTC](https://discourse.julialang.org/t/debugging-threads-spawn-applied-to-expr-data/61359/2 "2021-05-18T14:40:19Z")

</div>

`@macroexpand` is your friend. Maybe you need `Threads.@spawn $(eval(e))`? Although, using eval within a macro-call looks code-smelly to me.

---

<div class="post-metadata">

**Author:** ![ericsfraga](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ericsfraga/32/192_2.png) [@ericsfraga](https://discourse.julialang.org/u/ericsfraga)\
**Post date:** [May 19, 2021, 10:39am UTC](https://discourse.julialang.org/t/debugging-threads-spawn-applied-to-expr-data/61359/3 "2021-05-19T10:39:10Z")

</div>

Thank you for the suggestions. I’ll play around some more. Function call worked and I found an error in the expression but the silence was annoying.
