I’ve got a Julia module (which contains compiled Fortran code) which is called in Python using JuliaCall (Guide · PythonCall & JuliaCall), for example within a Python script:
from juliacall import Main as jl
jl.seval(using MyModule.jl)
Update, this is also the same using PyJulia. As soon as I import the module in the global scope and try call it within a function it instantly segfaults.
#!/usr/bin/env python3
from juliacall import Main as jl
jl.seval("using myModule")
def test_julia_import():
print(jl.myModule.molMassDict)
test_julia_import()
Interestingly this MWE works no problem. The problem arises when I try to do this inside a Django (I’m not sure if you’re familiar with Django but it’s a Web Dev framework) view. A Django view is similarly a Python function, for example:
def django_view(request):
test_julia()
if I call test_julia() within this, it instantly segfaults:
signal (11): Segmentation fault
in expression starting at none:0
Allocations: 6828442 (Pool: 6825828; Big: 2614); GC: 8
In case anyone comes here looking for answers, I’ve ended up moving the Julia code to it’s own microservice. The communication between Python and Julia is handled via requests (requests · PyPI) on the Python side and Genie on the Julia side.