Skip to content

Commit a60ef25

Browse files
gavin-aguiarGavin Aguiar
and
Gavin Aguiar
authored
Added worker to pythonpath (#1215)
* Added worker to pythonpath * Added constant for azure functions worker --------- Co-authored-by: Gavin Aguiar <gavin@GavinPC>
1 parent 8938bf6 commit a60ef25

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

python/prodV4/worker.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# User packages
77
PKGS_PATH = "site/wwwroot/.python_packages"
88
VENV_PKGS_PATH = "site/wwwroot/worker_venv"
9+
WORKER_DIR = "azure_functions_worker"
910

1011
PKGS = "lib/site-packages"
1112

@@ -50,18 +51,20 @@ def determine_user_pkg_paths():
5051

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

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

6265
if is_azure_environment():
6366
os.execve(sys.executable,
64-
[sys.executable, '-m', 'azure_functions_worker']
67+
[sys.executable, '-m', WORKER_DIR]
6568
+ sys.argv[1:],
6669
env)
6770
else:

0 commit comments

Comments
 (0)