mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
[processing] Avoid python hangs when run in headless mode from FCGI
This commit is contained in:
parent
0d5fb236ba
commit
59ec15bb2b
@ -73,7 +73,7 @@ class GdalUtils:
|
||||
fused_command,
|
||||
shell=True,
|
||||
stdout=subprocess.PIPE,
|
||||
stdin=subprocess.PIPE,
|
||||
stdin=open(os.devnull),
|
||||
stderr=subprocess.STDOUT,
|
||||
universal_newlines=False,
|
||||
).stdout
|
||||
|
@ -270,7 +270,7 @@ class GrassUtils:
|
||||
command,
|
||||
shell=True,
|
||||
stdout=subprocess.PIPE,
|
||||
stdin=subprocess.PIPE,
|
||||
stdin=open(os.devnull),
|
||||
stderr=subprocess.STDOUT,
|
||||
universal_newlines=True,
|
||||
).stdout
|
||||
@ -299,7 +299,7 @@ class GrassUtils:
|
||||
command,
|
||||
shell=True,
|
||||
stdout=subprocess.PIPE,
|
||||
stdin=subprocess.PIPE,
|
||||
stdin=open(os.devnull),
|
||||
stderr=subprocess.STDOUT,
|
||||
universal_newlines=True,
|
||||
).stdout
|
||||
|
@ -272,7 +272,7 @@ class Grass7Utils:
|
||||
command,
|
||||
shell=True,
|
||||
stdout=subprocess.PIPE,
|
||||
stdin=subprocess.PIPE,
|
||||
stdin=open(os.devnull),
|
||||
stderr=subprocess.STDOUT,
|
||||
universal_newlines=True,
|
||||
).stdout
|
||||
@ -301,7 +301,7 @@ class Grass7Utils:
|
||||
command,
|
||||
shell=True,
|
||||
stdout=subprocess.PIPE,
|
||||
stdin=subprocess.PIPE,
|
||||
stdin=open(os.devnull),
|
||||
stderr=subprocess.STDOUT,
|
||||
universal_newlines=True,
|
||||
).stdout
|
||||
|
@ -67,7 +67,7 @@ class FusionUtils:
|
||||
commands,
|
||||
shell=True,
|
||||
stdout=subprocess.PIPE,
|
||||
stdin=subprocess.PIPE,
|
||||
stdin=open(os.devnull),
|
||||
stderr=subprocess.STDOUT,
|
||||
universal_newlines=False,
|
||||
).stdout
|
||||
|
@ -46,7 +46,7 @@ class LAStoolsUtils:
|
||||
loglines = []
|
||||
loglines.append("LAStools console output")
|
||||
commandline = " ".join(commands)
|
||||
proc = subprocess.Popen(commandline, shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE,
|
||||
proc = subprocess.Popen(commandline, shell=True, stdout=subprocess.PIPE, stdin=open(os.devnull),
|
||||
stderr=subprocess.STDOUT, universal_newlines=False).stdout
|
||||
for line in iter(proc.readline, ""):
|
||||
loglines.append(line)
|
||||
|
@ -131,7 +131,7 @@ class OTBUtils:
|
||||
loglines.append("OTB execution console output")
|
||||
os.putenv('ITK_AUTOLOAD_PATH', OTBUtils.otbLibPath())
|
||||
fused_command = ''.join(['"%s" ' % c for c in commands])
|
||||
proc = subprocess.Popen(fused_command, shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE,stderr=subprocess.STDOUT, universal_newlines=True).stdout
|
||||
proc = subprocess.Popen(fused_command, shell=True, stdout=subprocess.PIPE, stdin=open(os.devnull),stderr=subprocess.STDOUT, universal_newlines=True).stdout
|
||||
for line in iter(proc.readline, ""):
|
||||
if "[*" in line:
|
||||
idx = line.find("[*")
|
||||
|
@ -103,7 +103,7 @@ class RUtils:
|
||||
command,
|
||||
shell=True,
|
||||
stdout=subprocess.PIPE,
|
||||
stdin=subprocess.PIPE,
|
||||
stdin=open(os.devnull),
|
||||
stderr=subprocess.STDOUT,
|
||||
universal_newlines=True,
|
||||
)
|
||||
@ -171,7 +171,7 @@ class RUtils:
|
||||
command,
|
||||
shell=True,
|
||||
stdout=subprocess.PIPE,
|
||||
stdin=subprocess.PIPE,
|
||||
stdin=open(os.devnull),
|
||||
stderr=subprocess.STDOUT,
|
||||
universal_newlines=True,
|
||||
).stdout
|
||||
|
@ -41,7 +41,7 @@ class SagaDescriptionCreator:
|
||||
command,
|
||||
shell=True,
|
||||
stdout=f2,
|
||||
stdin=subprocess.PIPE,
|
||||
stdin=open(os.devnull),
|
||||
stderr=subprocess.STDOUT,
|
||||
universal_newlines=True,
|
||||
)
|
||||
@ -77,7 +77,7 @@ class SagaDescriptionCreator:
|
||||
command,
|
||||
shell=True,
|
||||
stdout=f,
|
||||
stdin=subprocess.PIPE,
|
||||
stdin=open(os.devnull),
|
||||
stderr=f,
|
||||
universal_newlines=True,
|
||||
)
|
||||
|
@ -128,7 +128,7 @@ class SagaUtils:
|
||||
command,
|
||||
shell=True,
|
||||
stdout=subprocess.PIPE,
|
||||
stdin=subprocess.PIPE,
|
||||
stdin=open(os.devnull),
|
||||
stderr=subprocess.STDOUT,
|
||||
universal_newlines=True,
|
||||
).stdout
|
||||
|
@ -86,7 +86,7 @@ class TauDEMUtils:
|
||||
fused_command,
|
||||
shell=True,
|
||||
stdout=subprocess.PIPE,
|
||||
stdin=subprocess.PIPE,
|
||||
stdin=open(os.devnull),
|
||||
stderr=subprocess.STDOUT,
|
||||
universal_newlines=True,
|
||||
).stdout
|
||||
|
@ -323,13 +323,14 @@ class Processing:
|
||||
print 'Warning: Not all input layers use the same CRS.\n' \
|
||||
+ 'This can cause unexpected results.'
|
||||
|
||||
# Don't set the wait cursor twice, because then when you
|
||||
# restore it, it will still be a wait cursor.
|
||||
cursor = QApplication.overrideCursor()
|
||||
if cursor is None or cursor == 0:
|
||||
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
|
||||
elif cursor.shape() != Qt.WaitCursor:
|
||||
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
|
||||
if iface is not None:
|
||||
# Don't set the wait cursor twice, because then when you
|
||||
# restore it, it will still be a wait cursor.
|
||||
cursor = QApplication.overrideCursor()
|
||||
if cursor is None or cursor == 0:
|
||||
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
|
||||
elif cursor.shape() != Qt.WaitCursor:
|
||||
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
|
||||
|
||||
progress = None
|
||||
if iface is not None :
|
||||
@ -337,6 +338,8 @@ class Processing:
|
||||
ret = runalg(alg, progress)
|
||||
if onFinish is not None and ret:
|
||||
onFinish(alg, progress)
|
||||
QApplication.restoreOverrideCursor()
|
||||
progress.close()
|
||||
|
||||
if iface is not None:
|
||||
QApplication.restoreOverrideCursor()
|
||||
progress.close()
|
||||
return alg
|
||||
|
Loading…
x
Reference in New Issue
Block a user