Open toiletsandpaper opened 7 months ago
Looks like its caused by parallelization of python import. Minimal repro:
from python import Python
from algorithm import parallelize
fn do_something_python(text: String) raises -> PythonObject:
var uuid = Python.import_module('uuid')
return text + '\t' + str(uuid.uuid4())
fn main() raises:
var texts = DynamicVector[String]()
texts.append("Hello, World!")
texts.append("This is a test.")
texts.append("Hello, World!")
texts.append("This is a test.")
texts.append("Hello, World!")
texts.append("This is a test.")
texts.append("Hello, World!")
texts.append("This is a test.")
texts.append("Hello, World!")
texts.append("This is a test.")
# works just right
# for i in range(len(texts)):
# print(do_something_python(texts[i]))
@parameter
fn _do(i: Int):
try:
print(do_something_python(texts[i]))
except:
print('Error')
# parallelize[_do](1) # returns only UUID4, but not text... why?
parallelize[_do](len(texts))
p.s. IDK why, but paralellize[_do](1)
outputs something, that only Scooby Doo team is able to investigate
By the way, ffi.DLHandle
-> get_function
also doesn't work, resulting the same error
Bug description
I'm trying to parallelize my
classify
function over a DynamicVector of custom structs. But without parallelization code is very slow, even slower than python's approach, but this is probably because of my skill issue with sorting.Firstly, I've got a problem that without try-catching function that
raises
- I can't use any of parallelize function at all. Secondly, when I wrote somewhat a workaround - I got very shortseg fault
Steps to reproduce
seg_fault_parallelized
branch and it should install all withmake
locally https://github.com/toiletsandpaper/mojo_zlib_classification/blob/seg_fault_parallelized/README.mdSystem information