Madushan Pathirana
10/21/2025, 10:00 AMMarvin
10/21/2025, 10:00 AMMarvin
10/21/2025, 10:05 AM.submit(...) and direct task calls — that’s okay in Prefect 3. If you pass a PrefectFuture into another task (direct call or .submit), Prefect will automatically resolve the future to its value. More details: Run work concurrently and Task runners
- You’re passing a dict of large DataFrames/futures into upload_combine_excel. If that task is combining to Excel, it can be very memory hungry. An OOM kill will look exactly like this crash.
Recommended next steps to isolate the root cause
1) Surface more detail in the flow by forcing resolution and logging
- Capture the future for upload_combine_excel and call .result() to pull any failure into the flow logs (if it’s a normal failure, you’ll get a traceback; if it’s a crash, you’ll still just see crash but you’ll know it happens exactly there):
u = ebay_extraction.upload_combine_excel.with_options(
name="upload_combine_excel",
task_run_name="upload_combine_excel"
).submit(dataframe_dict, store_id)
# Block to surface errors/crashes in flow logs
u.result(raise_on_failure=False)
- Consider resolving upstream futures before combining to isolate which data causes trouble:
from prefect.futures import PrefectFuture
for k, v in list(dataframe_dict.items()):
if isinstance(v, PrefectFuture):
dataframe_dict[k] = v.result() # will raise on failure and log a traceback
2) Check the runtime that actually executed the task
- If you’re running on ECS:
- Open CloudWatch logs for the ECS task/container around the crash time. Look for OOMKilled or SIGKILL.
- Verify task memory/CPU settings. If you see OOM, increase memory limits or reduce memory usage in the task.
- If you’re running locally on EC2:
- Check the worker process logs (set PREFECT_LOGGING_LEVEL=DEBUG) and system logs (e.g., dmesg) for OOM kills.
- Ensure the worker itself isn’t restarting or being terminated.
3) Add defensive logging inside upload_combine_excel
- Log the number of sheets and the size of each DataFrame before writing. If you’re using pandas ExcelWriter, writing many large sheets can spike memory.
- If possible, stream writes (write one sheet at a time and free memory) or consider more compact formats (CSV/Parquet) if Excel is not strictly required.
4) Be cautious with tasks defined as instance methods
- If upload_combine_excel is an @task on a class instance (e.g., class EbayExtraction: @task def upload_combine_excel(self, ...)), that can be fragile in some remote/infrastructure contexts. Prefer top-level @task functions or @staticmethod tasks to avoid serialization/import issues.
Quick notes on Prefect 3 task semantics (to confirm your usage)
- Task.submit(...) returns a PrefectFuture. Use .result() to get the Python value if you need it in-flow. Docs: Task runners
- You can mix direct calls and .submit. Passing futures to other tasks is fine — Prefect resolves them automatically. Docs: Run work concurrentlyMarvin
10/21/2025, 10:05 AMupload_combine_excel task body (or at least how it writes the Excel)?
If you share those details, I can suggest concrete changes (e.g., streaming Excel writing approach, memory tuning, or ECS task sizing) tailored to your setup.