-
Notifications
You must be signed in to change notification settings - Fork 989
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
imp.load_source replacement #3441
Comments
Could be also replace with:
When we drop support for python 2 |
SourceFileLoader().load_module() seems to be deprecated too. This could be the solution for python 3:
|
@memsharded Just stumbled on this issue. As I faced exactly the same problem contributing to a different package manager, was wondering if this snippet might be useful to you: |
I've run into this while trying to parallelize recipe exporting with the following script: import sys
from pathlib import Path
from concurrent.futures import as_completed, ThreadPoolExecutor
from conans.client.conan_api import ConanAPIV1, _get_conanfile_path, cmd_export
def export_all(path: Path, namespace: str):
conan = ConanAPIV1()
conan.create_app()
user, channel = namespace.split("/")
sys.path.insert(0, str(Path.cwd().absolute() / "plexconantool"))
futures = []
path = Path(path)
conanfiles = list(sorted(
_get_conanfile_path(str(subdir.absolute()), cwd=None, py=True)
for subdir in path.iterdir()
))
with ThreadPoolExecutor(max_workers=12) as pool:
for cf in conanfiles:
ftr = pool.submit(
cmd_export,
conan.app,
cf,
name=None,
version=None,
user=user,
channel=channel,
keep_source=False,
graph_lock=None,
ignore_dirty=False,
)
futures.append(ftr)
for ftr in as_completed(futures):
ftr.result()
if __name__ == "__main__":
from argparse import ArgumentParser
parser = ArgumentParser()
parser.add_argument("directory", type=Path)
parser.add_argument("namespace")
args = parser.parse_args()
export_all(args.directory, args.namespace) I got this traceback, which to me appears to be a concurrency bug in
If I replace the load_source call with the snippet above, I get the following:
If I deactivate the attribute_checker hook, the issue disappears. I'm not sure why - |
Closed by #10127 |
Thanks to conan-io/conan#3441 for the inspiration
That function is already deprecated/undocumented.
#3340 tried to replace it with import, but failing in OSX Py3.6.
This has to be revisited and probably fixed for 2.0.
The text was updated successfully, but these errors were encountered: