Skip to content

Commit 1a77253

Browse files
authored
Separate run paths for Azure and local development (#570)
1 parent 9c7d7bd commit 1a77253

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

python/prod/worker.py

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import os
22
import sys
3-
import platform
4-
import subprocess
3+
54
from pathlib import Path
65

76
# User packages
@@ -42,25 +41,21 @@ def determine_user_pkg_paths():
4241

4342

4443
if __name__ == '__main__':
45-
user_pkg_paths = []
46-
if is_azure_environment():
47-
user_pkg_paths = determine_user_pkg_paths()
48-
49-
env = os.environ
5044
# worker.py lives in the same directory as azure_functions_worker
5145
func_worker_dir = str(Path(__file__).absolute().parent)
46+
env = os.environ
5247

53-
if platform.system() == 'Windows':
54-
joined_pkg_paths = ";".join(user_pkg_paths)
55-
env['PYTHONPATH'] = f'{joined_pkg_paths};{func_worker_dir}'
56-
# execve doesn't work in Windows: https://bugs.python.org/issue19124
57-
subprocess.run([sys.executable,
58-
'-m', 'azure_functions_worker'] + sys.argv[1:],
59-
env=env)
60-
else:
61-
joined_pkg_paths = ":".join(user_pkg_paths)
48+
if is_azure_environment():
49+
user_pkg_paths = determine_user_pkg_paths()
50+
51+
joined_pkg_paths = os.pathsep.join(user_pkg_paths)
6252
env['PYTHONPATH'] = f'{joined_pkg_paths}:{func_worker_dir}'
6353
os.execve(sys.executable,
6454
[sys.executable, '-m', 'azure_functions_worker']
6555
+ sys.argv[1:],
6656
env)
57+
else:
58+
sys.path.insert(1, func_worker_dir)
59+
from azure_functions_worker import main
60+
61+
main.main()

0 commit comments

Comments
 (0)