Skip to content

Commit

Permalink
(replicator) Fix sys.path after using the module_needed function
Browse files Browse the repository at this point in the history
In the module_needed function we alter the path of the python modules.
To be sure that we have no side effect, we revert this modification on
the end of the function

(cherry picked from commit ee7e771)
  • Loading branch information
neoclust committed Jan 23, 2025
1 parent fb8d7ae commit 9672410
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pulse_xmpp_agent/replicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ def prepare_folder_rollback(rollback_pulse_xmpp_agent, agent_folder):


def module_needed(agent_image, verbose=False):
original_sys_path = sys.path.copy()
# sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__))))
# create file __init.py si non exist
boolfichier = False
Expand Down Expand Up @@ -316,6 +317,7 @@ def module_needed(agent_image, verbose=False):
except BaseException:
print("Error while deleting file __init__.py")
if error:
sys.path = original_sys_path
return False

for filename in [
Expand All @@ -330,7 +332,9 @@ def module_needed(agent_image, verbose=False):
print(
f"Some python modules needed for running lib/{filename} are missing. We will not switch to new agent"
)
sys.path = original_sys_path
return False
sys.path = original_sys_path
return True


Expand Down

0 comments on commit 9672410

Please sign in to comment.