Skip to content

Revert: Added worker to pythonpath #1233

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 5 commits into from
May 8, 2023
Merged
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
7 changes: 2 additions & 5 deletions python/prodV4/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# User packages
PKGS_PATH = "site/wwwroot/.python_packages"
VENV_PKGS_PATH = "site/wwwroot/worker_venv"
WORKER_DIR = "azure_functions_worker"

PKGS = "lib/site-packages"

Expand Down Expand Up @@ -51,20 +50,18 @@ def determine_user_pkg_paths():

if __name__ == '__main__':
# worker.py lives in the same directory as azure_functions_worker
current_dir = str(Path(__file__).absolute())
worker_path = os.path.join(current_dir, WORKER_DIR)
func_worker_dir = str(Path(__file__).absolute().parent)
env = os.environ

# Setting up python path for all environments to prioritize
# third-party user packages over worker packages in PYTHONPATH
user_pkg_paths = determine_user_pkg_paths()
joined_pkg_paths = os.pathsep.join(user_pkg_paths)
env['PYTHONPATH'] = f'{worker_path}:{joined_pkg_paths}:{func_worker_dir}'
env['PYTHONPATH'] = f'{joined_pkg_paths}:{func_worker_dir}'

if is_azure_environment():
os.execve(sys.executable,
[sys.executable, '-m', WORKER_DIR]
[sys.executable, '-m', 'azure_functions_worker']
+ sys.argv[1:],
env)
else:
Expand Down