# HG changeset patch # User Louis 'Kureuil' Person # Date 1462053532 -7200 # Node ID aac47bc0711154c96eeff5e7508568be000266f6 # Parent 8acbab5a9f21756ce79423ad76b6b19aa70033bb Fix subprocess bufsize & master compilation diff -r 8acbab5a9f21 -r aac47bc07111 jupyter_c_kernel/kernel.py --- a/jupyter_c_kernel/kernel.py Sat Apr 30 23:48:19 2016 +0200 +++ b/jupyter_c_kernel/kernel.py Sat Apr 30 23:58:52 2016 +0200 @@ -12,7 +12,7 @@ self._write_to_stdout = write_to_stdout self._write_to_stderr = write_to_stderr - super().__init__(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + super().__init__(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=0) self._stdout_queue = Queue() self._stdout_thread = Thread(target=JupyterSubprocess._enqueue_output, args=(self.stdout, self._stdout_queue)) @@ -26,7 +26,7 @@ @staticmethod def _enqueue_output(contents, queue): - for line in iter(contents.readline, b''): + for line in iter(lambda: contents.read(4096), b''): queue.put(line) contents.close() @@ -63,7 +63,7 @@ os.close(mastertemp[0]) self.master_path = mastertemp[1] filepath = path.join(path.dirname(path.realpath(__file__)), '..', 'resources', 'master.c') - subprocess.call(['gcc', filepath, '-std=c11', '-fPIC', '-shared', '-rdynamic', '-o', self.master_path]) + subprocess.call(['gcc', filepath, '-std=c11', '-rdynamic', '-ldl', '-o', self.master_path]) def cleanup_files(self): """Remove all the temporary files created by the kernel"""