improving lock mechanism for office conversion: now check if context has timeout when trying to acquire the lock + office printer test

This commit is contained in:
Julien Neuhart
2019-07-23 16:40:39 +02:00
parent 0b2312a407
commit a524521fdb
5 changed files with 119 additions and 11 deletions

View File

@@ -34,13 +34,13 @@ func NewMergePrinter(logger xlog.Logger, fpaths []string, opts MergePrinterOptio
func (p mergePrinter) Print(destination string) error {
const op string = "printer.mergePrinter.Print"
logOptions(p.logger, p.opts)
/*
context.Context may be providen from
an officePrinter which needs to merge
its result files.
*/
if p.ctx == nil {
logOptions(p.logger, p.opts)
ctx, cancel := xcontext.WithTimeout(p.logger, p.opts.WaitTimeout)
defer cancel()
p.ctx = ctx