[FIX] Workaround to get printing done with 1 worker
bzr revid: sle@openerp.com-20140224134732-imptqwtzyoyml2qq
This commit is contained in:
parent
5557a1152c
commit
901172a194
|
@ -23,6 +23,7 @@ from openerp.osv.osv import except_osv
|
||||||
from openerp.addons.web import http
|
from openerp.addons.web import http
|
||||||
from openerp.tools.translate import _
|
from openerp.tools.translate import _
|
||||||
from openerp.addons.web.http import request
|
from openerp.addons.web.http import request
|
||||||
|
import openerp.tools.config as config
|
||||||
|
|
||||||
import time
|
import time
|
||||||
import base64
|
import base64
|
||||||
|
@ -35,6 +36,10 @@ try:
|
||||||
import cStringIO as StringIO
|
import cStringIO as StringIO
|
||||||
except ImportError:
|
except ImportError:
|
||||||
import StringIO
|
import StringIO
|
||||||
|
import psutil
|
||||||
|
import signal
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
from pyPdf import PdfFileWriter, PdfFileReader
|
from pyPdf import PdfFileWriter, PdfFileReader
|
||||||
from werkzeug import exceptions
|
from werkzeug import exceptions
|
||||||
|
@ -322,6 +327,12 @@ class Report(http.Controller):
|
||||||
content_file.seek(0)
|
content_file.seek(0)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
# If the server is running with only one worker, increase it to two to be able
|
||||||
|
# to serve the http request from wkhtmltopdf.
|
||||||
|
if config['workers'] == 1:
|
||||||
|
ppid = psutil.Process(os.getpid()).ppid
|
||||||
|
os.kill(ppid, signal.SIGTTIN)
|
||||||
|
|
||||||
wkhtmltopdf = command + command_args + command_arg_local
|
wkhtmltopdf = command + command_args + command_arg_local
|
||||||
wkhtmltopdf += [content_file.name] + [pdfreport.name]
|
wkhtmltopdf += [content_file.name] + [pdfreport.name]
|
||||||
|
|
||||||
|
@ -329,6 +340,9 @@ class Report(http.Controller):
|
||||||
stderr=subprocess.PIPE)
|
stderr=subprocess.PIPE)
|
||||||
out, err = process.communicate()
|
out, err = process.communicate()
|
||||||
|
|
||||||
|
if config['workers'] == 1:
|
||||||
|
os.kill(ppid, signal.SIGTTOU)
|
||||||
|
|
||||||
if process.returncode != 0:
|
if process.returncode != 0:
|
||||||
raise except_osv(_('Report (PDF)'),
|
raise except_osv(_('Report (PDF)'),
|
||||||
_('wkhtmltopdf-0.12 failed with error code = %s. '
|
_('wkhtmltopdf-0.12 failed with error code = %s. '
|
||||||
|
|
Loading…
Reference in New Issue