end</code></pre><h3 id="Dependencies"><a class="docs-heading-anchor" href="#Dependencies">Dependencies</a><a id="Dependencies-1"></a><a class="docs-heading-anchor-permalink" href="#Dependencies" title="Permalink"></a></h3><p>If your package depends on some Python packages, you must generate a <code>CondaPkg.toml</code> file. See <a href="#python-deps">Installing Python packages</a>.</p><h2 id="jl-multi-threading"><a class="docs-heading-anchor" href="#jl-multi-threading">Multi-threading</a><a id="jl-multi-threading-1"></a><a class="docs-heading-anchor-permalink" href="#jl-multi-threading" title="Permalink"></a></h2><div class="admonition is-warning" id="Warning-515ca28cb059d818"><header class="admonition-header">Warning<a class="admonition-anchor" href="#Warning-515ca28cb059d818" title="Permalink"></a></header><div class="admonition-body"><p>Multi-threading support is experimental and can change without notice.</p></div></div><p>From v0.9.22, PythonCall supports multi-threading in Julia and/or Python, with some caveats.</p><p>Most importantly, you can only call Python code while Python's <a href="https://docs.python.org/3/glossary.html#term-global-interpreter-lock">Global Interpreter Lock (GIL)</a> is locked by the current thread. Ordinarily, the GIL is locked by the main thread in Julia, so if you want to run Python code on any other thread, you must unlock the GIL from the main thread and then re-lock it while running any Python code on other threads.</p><p>This is made possible by the macros <a href="../pythoncall-reference/#PythonCall.GIL.@unlock"><code>PythonCall.GIL.@unlock</code></a> and <a href="../pythoncall-reference/#PythonCall.GIL.@lock"><code>PythonCall.GIL.@lock</code></a> or the functions <a href="../pythoncall-reference/#PythonCall.GIL.unlock"><code>PythonCall.GIL.unlock</code></a> and <a href="../pythoncall-reference/#PythonCall.GIL.lock"><code>PythonCall.GIL.lock</code></a> with this pattern:</p><pre><code class="language-julia hljs">PythonCall.GIL.@unlock Threads.@threads for i in 1:4
0 commit comments