Hello,
i want to convert a excel file into Pdf but the process hang at the following ligne of my function: workbook.SaveToFile("filename.pdf", FileFormat.PDF).
The function works fine on locahost but when i deployed my app and the enduser ist not able to use the fonction.
after debuging a found out that the function hang while executing workbook.SaveToFile("filename.pdf", FileFormat.PDF) and the server crashed afterward.
The functions worked 3 weeks without problem and yet no more.
her ist the code:
from spire.xls import *
from spire.xls.common import *
# Open an Excel XLS or XLSX file
workbook = Workbook()
workbook.LoadFromFile("Sample.xlsx")
# workbook.LoadFromFile("Sample.xls")
# Convert the Excel file to PDF format
workbook.SaveToFile("ExcelToPDF.pdf", FileFormat.PDF)
workbook.Dispose()
Hi… I think OOM is the primary suspect, particularly since .xlsx is a more memory-hungry format than the older (and more optimized) .xls is. What do you see in the logs (and RAM-usage metrics) when the server crashes?
Hello Mayailurus,
in the fly logs nothing is populated. I see only after something like 30 seconds that the VM will restart. No error is populated caused by the codeline workbook.saveToFile. That is my problem
The logs will at least show the exit code from the program and the restarting. This would be useful information and can rule in or rule out out of memory conditions.
Working on your machine, working previously with a small workbook and failing now with a potentially larger workbook, all are signs that your machine may be memory constrained.
Hello rubys,
i ran the function again and check in the logs. i saw this time the following error:
App App-Name has excess capacity, autostopping machine 56830997b7xxxx. 0 out of 1 machines left running (region=ams, process group=app)
I anhanced the size of the app (which contains the instance 56830997b7xxxx) from 1Gb to 2Gb but i have almost the same error for the 2 instance of the app:
App App-name has excess capacity, autostopping machine 56830997b7xxxx. 1 out of 2 machines left running (region=ams, process group=app)
App App-name has excess capacity, autostopping machine e2867002b4xxxx. 0 out of 1 machines left running (region=ams, process group=app)
auto stopping (which is configured in your fly.toml) happens if your web application has responded to a request and no new request comes in within a reasonable period of time (I don’t recall the exact amount of time, but it is a small number of minutes).
If you have a web application which accepts requests, produces responses, and continues to process background jobs you don’t want auto-stop configured. Set it to “off”. If you still want your machine to stop when not in use, have it exit with a exit code of 0 when idle.
Hello,
thank you all for you contributions.
The problem was realy related to the Memory and CPU.
i decided to use canvas from reportlab.pdfgen to copy my excel row per row in a blank pdf.
and i designed the pdf to looks like the format of the excel afterward with few rows of code.
The functon with canvas run in production (VM) faster than the function with workbook.LoadFromFile("Sample.xls") of Spire.xls in my local computer.