changeset 37:aac47bc07111

Fix subprocess bufsize & master compilation
author Louis 'Kureuil' Person <louis.person@epitech.eu>
date Sat, 30 Apr 2016 23:58:52 +0200
parents 8acbab5a9f21
children cb587f21c8bb
files jupyter_c_kernel/kernel.py
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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"""