Using the python multiprocessing module for IO with pygame on Mac OS 10.7

亡梦爱人 提交于 2019-12-03 10:43:19

Maybe you should initialize the pygame (which initialize SDL-> OpenGL) in each forked (child) process like in sample:

import multiprocessing

def f():
  import pygame
  pygame.init()

  while True:
    pygame.event.pump()

if __module__ == "__main__"
  p = multiprocessing.Process(target=f)
  p.start()

  import pygame
  pygame.init()

  while True:
    pygame.event.pump()

Try this link:

http://www.slideshare.net/dabeaz/an-introduction-to-python-concurrency#btnPrevious

It may help. The problem is that you are creating a process that never stops. This should be declared as a daemon:

p = multiprocessing.Process(target=f)
p.daemon = True
p.start()

Not sure if this will solve the problem, I'm just learning about the multiprocessing module as I'm posting this.

Have you tried using threads instead of processes? I've had issues before using the python multiprocessing module in OS X. http://docs.python.org/library/threading.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!