Timeout option in APIs

Hi all, I really need a timeout for all the APIs but it is still missing. Is that right? Do you plan to implement it?

I am asking that because I am building a search engine and I cannot wait forever for document conversion and text extraction. Aspose writes that some of its clients produce search engine, so how do they solve the conversion timeout problem?
Thanks,
Diego

Hi Diego,

Can you please further elaborate your requirement e.g. which input formats are you using and what are your desired output formats? Please attach some samples if Aspose takes longer time to convert them or extract text.

Best Regards,

Hi, actually I need to solve the problem for any kind of input and output managed by Aspose.Pdf, Aspose.Words, Aspose.Email, Aspose.Cells, and Aspose.Slides.In particualr, it is necessary that the conversion time for a document does not not exceed 1 sec. How can I do that?


Thanks,
Diego

Hi Diego,

This feature is not supported by any API. We will log these issues and share the IDs with you soon.

Best Regards,

Hi Diego,

I have observed your requirement and have added an issue with ID SLIDESNET-36244 as new feature request in our issue tracking system to investigate the possibility of implementing the requested support. This thread has been linked with the issue so that you may be automatically notified once the issue will be resolved.

Many Thanks,

Hi Diego,


I have logged your request in our database under the ticket CELLSNET-43461 in order to investigate its feasibility in Aspose.Cells’ scope. The said ticket is now attached to this thread for automated notifications.

Please feel free to get in touch in case you have any further concerns or questions.

Hi again,


This is to inform you that the current implementation of Aspose.Cells APIs provide one mechanism to handle similar situation while using the Aspose.Cells.InterruptMonitor class. This mechanism needs two threads to handle the process where one thread has to be used for loading/saving Workbook and other for checking the time and interrupt the process.

Please note, the Aspose.Cells APIs only support this mechanism for loading XLS/XLSX template files at the moment. You may try the loading process with this approach to check whether it can fit your requirement. If you are satisfied and want us to provide the same support for saving process and other file formats, we may enhance this mechanism in future revisions of Aspose.Cells APIs.

Here is the sample code for your reference.

C#

class MTTest
{
private string _path;
private InterruptMonitor _monitor;
private Workbook _wb;
public MTTest(string path)
{
_path = path;
_monitor = new InterruptMonitor();
}
public void InterruptLoad()
{
_monitor.Interrupt();
}
public void Load()
{
LoadOptions opts = new LoadOptions();
opts.InterruptMonitor = _monitor;
Console.WriteLine(“Loading template file…”);
long t = DateTime.Now.ToFileTimeUtc();
try
{
_wb = new Workbook(_path, opts);
Console.WriteLine(“Template file has been loaded”);
}
catch (CellsException ce)
{
if (ce.Code == ExceptionType.Interrupted)
{
Console.WriteLine(“Load process has been interrupted.”);
}
else
{
throw ce;
}
}
}
}


MTTest tho = new MTTest(infile);
Thread th = new Thread(new ThreadStart(tho.Load));
th.Start();
Thread.Sleep(1000);
tho.InterruptLoad();

@diego.tosato,

We suggest you to please try using following sample code on your end using latest Aspose.Slides for .NET 20.1 for setting TimeOut options.

      public static void SavePresentationToPdf()
        {
            Action<IInterruptionToken> action = (IInterruptionToken token) =>
            {
                LoadOptions options = new LoadOptions { InterruptionToken = token };
                using (Presentation presentation = new Presentation(pptxFileName, options))
                {
                    presentation.Save(pdfFileName, SaveFormat.Pdf);
                }
            };

            InterruptionTokenSource tokenSource = new InterruptionTokenSource();
            Run(action, tokenSource.Token); // run action in a separate thread
            Thread.Sleep(10000);            // timeout
            tokenSource.Interrupt();        // stop conversion
        }

        private static void Run(Action<IInterruptionToken> action, IInterruptionToken token)
        {
            Task.Run(() => { action(token); });
        }

@diego.tosato,
This is to inform you that we have fixed your issue (logged earlier as “CELLSNET-43461”) now. We will soon provide you the fixed version after performing QA and incorporating other enhancements and fixes.