Skip to content

Commit

Permalink
Improve emulator support for python functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
taeold committed Jan 24, 2023
1 parent 4f0adef commit eb15111
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/emulator/functionsEmulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ export class FunctionsEmulator implements EmulatorInstance {
/.+?[\\\/]node_modules[\\\/].+?/, // Ignore node_modules
/(^|[\/\\])\../, // Ignore files which begin the a period
/.+\.log/, // Ignore files which have a .log extension
/.+?[\\\/]venv[\\\/].+?/, // Ignore site-packages in venv
],
persistent: true,
});
Expand Down Expand Up @@ -1320,6 +1321,10 @@ export class FunctionsEmulator implements EmulatorInstance {
const childProcess = runWithVirtualEnv(args, backend.functionsDir, {
...process.env,
...envs,
// Required to flush stdout/stderr immediately to the piped channels.
PYTHONUNBUFFERED: "1",
// Required to prevent flask development server to reload on code changes.
DEBUG: "False",
HOST: "127.0.0.1",
PORT: port.toString(),
});
Expand Down
2 changes: 1 addition & 1 deletion src/functions/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function runWithVirtualEnv(
return spawn(command, args, {
shell: true,
cwd,
stdio: [/* stdin= */ "ignore", /* stdout= */ "pipe", /* stderr= */ "pipe"],
stdio: [/* stdin= */ "pipe", /* stdout= */ "pipe", /* stderr= */ "pipe", "pipe"],
// Linting disabled since internal types expect NODE_ENV which does not apply to Python runtimes.
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any
env: envs as any,
Expand Down

0 comments on commit eb15111

Please sign in to comment.