From e82f7c5b4210542adc7a9d9f83ef0a1e6b417389 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Tue, 24 Mar 2020 15:08:26 +0100 Subject: Fix process termination problem --- gas.py | 26 +++++++++++++------------- shell.nix | 1 - 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/gas.py b/gas.py index 290bf6e..f49d6ec 100644 --- a/gas.py +++ b/gas.py @@ -254,7 +254,6 @@ class VelocityHistogram: glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 4*np.dtype(np.float32).itemsize, ctypes.c_void_p(2*np.dtype(np.float32).itemsize)) self.texture_id = glGenTextures(2) - print(self.texture_id) glBindTexture(GL_TEXTURE_2D, self.texture_id[0]) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); @@ -267,7 +266,7 @@ class VelocityHistogram: def update(self): self.steps = self.steps + 1 - if self.steps % 100 == 0 and self.plotter == None: + if self.steps % 50 == 0 and self.plotter == None: self.plotter = self.pool.submit(get_histogram, self.gas.get_velocity_norms()) else: @@ -319,10 +318,10 @@ histogram = VelocityHistogram(gas, [1.1,0], [1,1]) histogram.setup() view = View(gas, [ ColoredBox([0,0], [1,1], (1,1,1)), tracer ], [ histogram ]) -running = False +active = False def on_display(): - if running: + if active: for i in range(0,5): gas.evolve() @@ -339,16 +338,17 @@ def on_timer(t): glutPostRedisplay() def on_keyboard(key, x, y): - global running - running = not running + global active + active = not active def on_close(): - histogram.pool.shutdown(wait=True) + histogram.pool.shutdown() -glutDisplayFunc(on_display) -glutReshapeFunc(on_reshape) -glutTimerFunc(10, on_timer, 10) -glutKeyboardFunc(on_keyboard) -glutCloseFunc(on_close) +if __name__ == "__main__": + glutDisplayFunc(on_display) + glutReshapeFunc(on_reshape) + glutTimerFunc(10, on_timer, 10) + glutKeyboardFunc(on_keyboard) + glutCloseFunc(on_close) -glutMainLoop() + glutMainLoop() diff --git a/shell.nix b/shell.nix index 9122012..d82cbe3 100644 --- a/shell.nix +++ b/shell.nix @@ -23,7 +23,6 @@ pkgs.stdenvNoCC.mkDerivation rec { local-python = custom-python.withPackages (python-packages: with python-packages; [ numpy - sympy scipy pyopencl setuptools pyopengl pyrr -- cgit v1.2.3