JuliaPy / JuliaPy/PythonCall.jl
Threaded test succeeds on `pytest` and fails on `tox`
- Ngôn ngữ chính
- Julia
- Star
- 1.1k
- Fork
- 86
- Merge trung bình
- 1 ngày 22 giờ
- Pull request đã merge (30 ngày)
- 3
Mô tả
**Affects:** JuliaCall
**Describe the bug**
When I run the following MWE, the code succeeds when run under `pytest` but hangs forever under `tox`, presumably because `pytest` is launching the test from the main thread? I have `JULIA_NUM_THREADS` set to `auto`.
```
from juliacall import Main as jl
import pytest
from concurrent.futures import ThreadPoolExecutor, as_completed, wait
def test_sample():
jl.seval("""
function my_sqr()
a = rand(20, 20)
Threads.@threads for ii in 1:size(a, 1)
for jj in 1:size(a, 2)
a[ii,jj] = a[ii,jj]^2
end
end
return
end
""")
pool = ThreadPoolExecutor(2)
fs = {pool.submit(jl.my_sqr._jl_call_nogil): ix for ix in range(10)}
for future in as_completed(fs):
rank = fs[future]
results = future.result()
print(results)
```
If I run
`bs = [my_sqr() for ix in range(10)]`
instead in the test, everything works fine in both `tox` and `pytest`.
**Your system**
This is on PythonCall/juliacall 0.9.22 and Julia 1.10.4, Python 3.10.14, Mac M2.
**Additional context**
Add any other context about the problem here.
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Hướng nghiên cứu
Start by running the supplied MWE under both pytest and tox with the reported PythonCall, JuliaCall, Julia, and Python versions, then compare the threaded execution behavior. The issue is resolved when the ThreadPoolExecutor calls complete under tox as they do under pytest, without changing the sequential case.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- testing
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100