Skip to content

[Bug] Python worker restarts repeatedly because of python cache generation #1665

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

Open
stewartadam opened this issue Apr 9, 2025 · 2 comments

Comments

@stewartadam
Copy link

Expected Behavior

Functions should not get caught in reboot loops because of automatic pycache generation
User should not manually have to disable pycache generation

Actual Behavior

As pycache or .pyc files are auto-written to disk, the file change triggers a worker restart causing reboot loops as the function initalizes

Steps to Reproduce

  1. Deploy a Python app from ZIP without pycache folders included

Relevant code being tried

Relevant log output

requirements.txt file

Where are you facing this problem?

Production Environment (explain below)

Function app name

No response

Additional Information

Filesystem monitoring should ignore __pycache__ / .pyc files, or the worker environment should set PYTHONPYCACHEPREFIX to avoid issues.

See #366

@hallvictoria
Copy link
Contributor

Hi @stewartadam, thanks for reporting. Setting this environment variable to true by default would have performance impacts (and potentially other unintended effects), which would impact all customers, not just those who use Docker. It would require extensive testing on our end, and it's not something we're looking at right now.

There are workarounds provided specifically for customers who use Docker, as mentioned in the previous issue. We can add this environment variable into the Dockerfile generated by CoreTools to help with this, but the change would be in that Dockerfile, not the worker.

@stewartadam
Copy link
Author

I'm not sure this is docker-specific - I was bumping against this running with a ZIP deployment.

Out of curiosity, what are the perf impacts you mentioned? AFAIK PYTHONPYCACHEPREFIX should just set location of generated Python cache, not stop cache generation alltogether.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants