I’m encountering a sudden memory error in my background-task workflow:
Error:
anvil.server.ExecutionTerminatedError: Server code exited unexpectedly: e33a7cea3a
Symptoms: The process is killed due to apparent out-of-memory when I enqueue more than three anvil.server.launch_background_task calls in quick succession.
What’s puzzling:
No changes have been made to the code or the database since yesterday.
Yesterday I successfully launched the same tasks (even five at once) without any issues.
The data volume and task logic are identical; nothing else in my environment has changed.
Has anyone seen a recent change in memory limits for background tasks? Or found a reliable pattern to enqueue bursts of tasks without exhausting RAM? Any insights or best practices would be greatly appreciated.
I’ve never had this problem myself, but I’m running on a dedicated server. If you’re on a shared plan, Anvil might be terminating your process if it sees too many resources being used.
One thing you could try is building a task manager that runs your background tasks in sequence, or limits the number running in parallel. Instead of directly launching several tasks at once, you’d ask your task manager to start them one at a time, or a few at a time, avoiding bursts of concurrent executions.
Depending on your task architecture, you may also be able to rewrite a sequence of background tasks as a single task. Since it has just one Python interpreter instance, it should have less overhead than multiple simultaneous instances.