##// END OF EJS Templates
Redirect unused pipes to devnull
Takafumi Arakaki -
Show More
@@ -19,6 +19,7 b' from __future__ import print_function'
19
19
20 import bdb
20 import bdb
21 import signal
21 import signal
22 import os
22 import sys
23 import sys
23 import time
24 import time
24 import tempfile
25 import tempfile
@@ -269,23 +270,23 b' class ZMQTerminalInteractiveShell(TerminalInteractiveShell):'
269 imageformat = self._imagemime[mime]
270 imageformat = self._imagemime[mime]
270 fmt = dict(format=imageformat)
271 fmt = dict(format=imageformat)
271 args = [s.format(**fmt) for s in self.stream_image_handler]
272 args = [s.format(**fmt) for s in self.stream_image_handler]
272 proc = subprocess.Popen(
273 with open(os.devnull, 'w') as devnull:
273 args, stdin=subprocess.PIPE,
274 proc = subprocess.Popen(
274 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
275 args, stdin=subprocess.PIPE,
275 proc.communicate(raw)
276 stdout=devnull, stderr=devnull)
277 proc.communicate(raw)
276
278
277 def handle_image_tempfile(self, data, mime):
279 def handle_image_tempfile(self, data, mime):
278 raw = base64.decodestring(data[mime])
280 raw = base64.decodestring(data[mime])
279 imageformat = self._imagemime[mime]
281 imageformat = self._imagemime[mime]
280 ext = '.{0}'.format(imageformat)
282 ext = '.{0}'.format(imageformat)
281 with tempfile.NamedTemporaryFile(suffix=ext) as f:
283 with tempfile.NamedTemporaryFile(suffix=ext) as f, \
284 open(os.devnull, 'w') as devnull:
282 f.write(raw)
285 f.write(raw)
283 f.flush()
286 f.flush()
284 fmt = dict(file=f.name, format=imageformat)
287 fmt = dict(file=f.name, format=imageformat)
285 args = [s.format(**fmt) for s in self.tempfile_image_handler]
288 args = [s.format(**fmt) for s in self.tempfile_image_handler]
286 subprocess.Popen(
289 subprocess.call(args, stdout=devnull, stderr=devnull)
287 args, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
288 ).communicate()
289
290
290 def handle_image_callable(self, data, mime):
291 def handle_image_callable(self, data, mime):
291 self.callable_image_handler(data)
292 self.callable_image_handler(data)
General Comments 0
You need to be logged in to leave comments. Login now