Skip to content

Commit b67d360

Browse files
committedApr 16, 2013
[pyqgis-console] fix interrupted system call on run script for osx
1 parent 256d28e commit b67d360

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed
 

‎python/console/console_editor.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,16 +395,30 @@ def runScriptCode(self):
395395
else:
396396
try:
397397
p = subprocess.Popen(['python', filename], shell=False, stdin=subprocess.PIPE, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
398-
traceback = p.stderr.read()
399-
out = p.stdout.read()
398+
out, traceback = p.communicate()
399+
400+
## Fix interrupted system call on OSX
401+
if sys.platform == 'darwin':
402+
status = None
403+
while status is None:
404+
try:
405+
status = p.wait()
406+
except OSError, e:
407+
if e.errno == 4:
408+
pass
409+
else:
410+
raise e
411+
400412
if traceback:
401413
print "## %s" % datetime.datetime.now()
402414
print "## Script error: %s" % name
403415
sys.stderr.write(traceback)
416+
p.stderr.close()
404417
else:
405418
print "## %s" % datetime.datetime.now()
406419
print "## Script executed successfully: %s" % name
407420
sys.stdout.write(out)
421+
p.stdout.close()
408422
del p
409423
#execfile(unicode(filename))
410424
except IOError, error:

0 commit comments

Comments
 (0)
Please sign in to comment.