Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I would personally suggest writing this without using the <code>multiprocessing</code> module: it uses <code>fork()</code> which has unspecified effects with most complex libraries, like in this case <code>pygame</code>.</p> <p>You should try to write this as two completely separate programs. It forces you to think about what data needs to go from one to the other, which is both a bad and a good thing (as it may clarify things). You can use some inter-process communication facility, like the stdin/stdout pipe; e.g. in one program (the "main" one) you start the other as a sub-process like this:</p> <pre><code>popen = subprocess.Popen([sys.executable, '-u', 'my_subproc.py'], stdin=subprocess.PIPE, stdout=subprocess.PIPE) </code></pre> <p>(The <code>-u</code> is for unbuffered.)</p> <p>Then read/write the data to popen.stdin/popen.stdout in the parent process, and to sys.stdin/sys.stdout in the subprocess. The simplest example would be if the two processes only need a synchronization signal, e.g. the parent process waits in a loop for the subprocess to say "next please". To do this the subprocess does <code>print 'next please'</code>, and the parent process does <code>popen.stdin.readline()</code>. (The print goes to sys.stdin in the subprocess.)</p> <p>Unrelated small note:</p> <pre><code>keypress = ['K_p', ...] ... cmd = compile('cond = keys['+i+']', '&lt;string&gt;', 'exec') exec cmd if cond: </code></pre> <p>This looks like very heavy code to just do:</p> <pre><code>keypress = [K_p, ...] # not strings, directly the values ... if keys[i]: </code></pre>
    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.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      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