Skip to content

Commit 0767162

Browse files
committed
Use subprocess.run for Windows rather than execve
1 parent fcacb64 commit 0767162

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

python/prod/worker.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import sys
33
import platform
4+
import subprocess
45
from pathlib import Path
56

67
# User packages
@@ -52,10 +53,14 @@ def determine_user_pkg_paths():
5253
if platform.system() == 'Windows':
5354
joined_pkg_paths = ";".join(user_pkg_paths)
5455
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)
5560
else:
5661
joined_pkg_paths = ":".join(user_pkg_paths)
5762
env['PYTHONPATH'] = f'{joined_pkg_paths}:{func_worker_dir}'
58-
59-
os.execve(sys.executable,
60-
[sys.executable, '-m', 'azure_functions_worker'] + sys.argv[1:],
61-
env)
63+
os.execve(sys.executable,
64+
[sys.executable, '-m', 'azure_functions_worker']
65+
+ sys.argv[1:],
66+
env)

0 commit comments

Comments
 (0)