Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing the python multiprocessing module for IO with pygame on Mac OS 10.7
    primarykey
    data
    text
    <p>I use pygame for running experiments in cognitive science, and often I have heavy I/O demands so I like to fork off these tasks to separate processes (when using a multi-core machine) to improve performance of my code. However, I encountered a scenario where some code works on my colleague's linux machine (Ubuntu LTS), but not on my mac. Below is code representing a minimal reproducible example. My mac is a 2011 Macbook Air running 10.7.2 and using the default python 2.7.1. I tried both pygame as installed via <a href="http://www.pygame.org/ftp/pygame-1.9.2pre-py2.7-macosx10.7.mpkg.zip">pre-built binary</a>, and I also then tried after installing both SDL and pygame from source.</p> <pre><code>import pygame import multiprocessing pygame.init() def f(): while True: pygame.event.pump() #if this is replaced by pass, this code works p = multiprocessing.Process(target=f) p.start() while True: pass </code></pre> <p>As noted in the code, it seems that the culprit is putting <code>pygame.event.pump()</code> in a separate process. When I run this on my mac, I first get the following printed repeatedly in terminal:</p> <pre><code>The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec(). Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug. </code></pre> <p>Then I get a crash report as copied to <a href="https://gist.github.com/1360815">this gist</a>.</p> <p>Any suggestions for how to fix this?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload