Skip to content

joblib threading issue with esig #116

@terrylyons

Description

@terrylyons

the work around
`# returns a list of signatures using parallel processing
import esig, joblib, numpy as np
def parallel_stream2sig(paths,depth):
return joblib.Parallel(n_jobs=-1)(joblib.delayed(esig.stream2sig)(x,depth) for x in paths)

paths = [np.random.rand(20,2) for i in range (10)]

print(parallel_stream2sig(paths,4))`

works but
`# returns a list of signatures using parallel processing
import esig, joblib, numpy as np
def parallel_stream2sig(paths,depth):
return joblib.Parallel(n_jobs=-1, prefer="threads")(joblib.delayed(esig.stream2sig)(x,depth) for x in paths)

paths = [np.random.rand(20,2) for i in range (10)]

print(parallel_stream2sig(paths,4))`

causes the following crash:

Traceback (most recent call last):
File "C:\Users\t\source\repos\esig_batch\esig_batch\esig_batch.py", line 9, in
print(parallel_stream2sig(paths,4))
File "C:\Users\t\source\repos\esig_batch\esig_batch\esig_batch.py", line 5, in parallel_stream2sig
return joblib.Parallel(n_jobs=-1, prefer="threads")(joblib.delayed(esig.stream2sig)(x,depth) for x in paths)
File "C:\Users\t\source\repos\esig_batch\esig_batch\env\lib\site-packages\joblib\parallel.py", line 1054, in call
self.retrieve()
File "C:\Users\t\source\repos\esig_batch\esig_batch\env\lib\site-packages\joblib\parallel.py", line 933, in retrieve
self.output.extend(job.get(timeout=self.timeout))
File "C:\users\t\source\Python37_64\lib\multiprocessing\pool.py", line 657, in get
raise self.value
File "C:\users\t\source\Python37_64\lib\multiprocessing\pool.py", line 121, in worker
result = (True, func(*args, **kwds))
File "C:\Users\t\source\repos\esig_batch\esig_batch\env\lib\site-packages\joblib_parallel_backends.py", line 595, in call
return self.func(*args, **kwargs)
File "C:\Users\t\source\repos\esig_batch\esig_batch\env\lib\site-packages\joblib\parallel.py", line 263, in call
for func, args, kwargs in self.items]
File "C:\Users\t\source\repos\esig_batch\esig_batch\env\lib\site-packages\joblib\parallel.py", line 263, in
for func, args, kwargs in self.items]
File "C:\Users\t\source\repos\esig_batch\esig_batch\env\lib\site-packages\esig_init
.py", line 133, in wrapper
return func(as_array, *args, **kwargs)
File "C:\Users\t\source\repos\esig_batch\esig_batch\env\lib\site-packages\esig_init
.py", line 151, in stream2sig
backend = get_backend()
File "C:\Users\t\source\repos\esig_batch\esig_batch\env\lib\site-packages\esig\backends.py", line 35, in get_backend
return _BACKEND_CONTAINER.context
AttributeError: '_thread._local' object has no attribute 'context'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions