import multiprocessing in module level

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

import multiprocessing in module level

keteage
In module `owlready2.driver`, python `multiprocessing` is imported within the method definition.
This is not allowing callers to monkey patch `multiprocessing`.

Is it possible to move the import statement to module level import?

Thank you,
Vishnu G
Reply | Threaded
Open this post in threaded view
|

Re: import multiprocessing in module level

Jiba
Administrator
Hello,

The import is deliberately put inside the method, in order to import multiprocessing only if needed (= only if a huge ontology is loaded), and inside a try... block (multiprocessing may not be available on some platform).

Nevertheless, I think you can still monkey patch multiprocessing before importing owlready2: just import multiprocessing before owlready2 and modify the multiprocessing module?

Jiba