# Julia multithreading from pycall - possible to overcome?

**URL:** <https://discourse.julialang.org/t/julia-multithreading-from-pycall-possible-to-overcome/78538>\
**Category:** Specific Domains\
**Tags:** question\
**Created:** [March 27, 2022, 1:29am UTC](https://discourse.julialang.org/t/julia-multithreading-from-pycall-possible-to-overcome/78538 "2022-03-27T01:29:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fatafim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fatafim/32/34957_2.png) [@Fatafim](https://discourse.julialang.org/u/Fatafim)\
**Post date:** [March 27, 2022, 1:29am UTC](https://discourse.julialang.org/t/julia-multithreading-from-pycall-possible-to-overcome/78538/1 "2022-03-27T01:29:46Z")

</div>

Say I have a jupyter notebook:

> %%julia
> 
> using Pkg  
> Pkg.add(“DecisionTree”)  
> using DecisionTree
> 
> X = Vector([1.1,2.2,3.3])  
> Y = Vector([1.1,2.2,3.3])  
> X = reshape(X, size(X))
> 
> X = Float32.(X)  
> Y = Float32.(Y)  
> print(typeof(X))  
> print(typeof(Y))  
> model = DecisionTree.build\_forest(Y, X’)

From what I know DecisionTree.jl uses multithreading, which pycall does not support, which results in the error:

> RuntimeError: \<PyCall.jlwrap (in a Julia function called from Python)  
> JULIA: TaskFailedException  
> Stacktrace:  
> [1] wait  
> @ .\task.jl:334 [inlined]  
> [2] threading\_run(func::Function)  
> @ Base.Threads .\threadingconstructs.jl:38  
> [3] macro expansion  
> @ .\threadingconstructs.jl:97 [inlined]  
> [4] build\_forest(labels::Vector{Float32}, features::LinearAlgebra.Adjoint{Float32, Vector{Float32}}, n\_subfeatures::Int64, n\_trees::Int64, partial\_sampling::Float64, max\_depth::Int64,

My question is - is there any way to make it work after all?

---

<div class="post-metadata">

**Author:** ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Post date:** [March 28, 2022, 5:46am UTC](https://discourse.julialang.org/t/julia-multithreading-from-pycall-possible-to-overcome/78538/2 "2022-03-28T05:46:45Z")

</div>

Running into similar problems with PythonCall.jl, so I’m definitely interested in the answer

---

<div class="post-metadata">

**Author:** ![goerch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerch/32/29122_2.png) [@goerch](https://discourse.julialang.org/u/goerch)\
**Post date:** [March 28, 2022, 7:04am UTC](https://discourse.julialang.org/t/julia-multithreading-from-pycall-possible-to-overcome/78538/3 "2022-03-28T07:04:11Z")

</div>

[https://stackoverflow.com/questions/71632579/julia-multithreading-from-pycall](https://stackoverflow.com/questions/71632579/julia-multithreading-from-pycall)

---

<div class="post-metadata">

**Author:** ![Fatafim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fatafim/32/34957_2.png) [@Fatafim](https://discourse.julialang.org/u/Fatafim)\
**Post date:** [March 28, 2022, 9:05am UTC](https://discourse.julialang.org/t/julia-multithreading-from-pycall-possible-to-overcome/78538/4 "2022-03-28T09:05:09Z")

</div>

@gdalle, @goerch actually posted my own question on stackoverflow xD anyways, the problem is the size and type of the inputs, in julia the errors are kind of counterintuitive. If you have any further problem, let us know here, since my problem is solved maybe we could help you
