Skip to content

HTCONDOR-2688 fix-module-load #632

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

Merged
merged 2 commits into from
Mar 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/htcondorce/web.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@

import os
import re
import importlib
import importlib.machinery
import importlib.util
import json
import time
import logging
Expand Down Expand Up @@ -114,7 +115,10 @@ def check_initialized(environ):
if not filename.endswith(".py"):
continue
name = filename[:-3]
plugin = importlib.load_source(name, os.path.join(plugins_dir, filename))
loader = importlib.machinery.SourceFileLoader(name, os.path.join(plugins_dir, filename))
spec = importlib.util.spec_from_loader(loader.name, loader)
plugin = importlib.util.module_from_spec(spec)
loader.exec_module(plugin)
if validate_plugin(name, plugin):
log.debug("plugin %s: loaded ok", name)
_plugins.append(plugin)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_condor_ce_router_defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
loader = importlib.machinery.SourceFileLoader('condor_ce_router_defaults', DEFAULTS_PATH)
spec = importlib.util.spec_from_loader(loader.name, loader)
defaults = importlib.util.module_from_spec(spec)
loader.exec(defaults)
loader.exec_module(defaults)

class TestDefaults(unittest.TestCase):
"""Unit tests for condor_ce_router_defaults"""
Expand Down
8 changes: 6 additions & 2 deletions tests/test_verify_ce_config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/python3
"""Unit tests for verify_ce_config.py"""

import importlib
import importlib.machinery
import importlib.util
import os
import unittest

Expand Down Expand Up @@ -36,7 +37,10 @@
'''

VERIFY_PATH = os.path.join('..', 'src', 'verify_ce_config.py')
verify = importlib.load_source('verify_ce_config', VERIFY_PATH)
loader = importlib.machinery.SourceFileLoader('verify_ce_config', VERIFY_PATH)
spec = importlib.util.spec_from_loader(loader.name, loader)
verify = importlib.util.module_from_spec(spec)
loader.exec_module(verify)


class TestVerifyConfig(unittest.TestCase):
Expand Down
Loading