Can I add pygame events from a second thread

后端 未结 1 647
没有蜡笔的小新
没有蜡笔的小新 2021-01-13 18:33

Well I have read at various places that the pygame event handling must be done in the main thread. I want to do that but my question is, can I add events to the event queue

相关标签:
1条回答
  • 2021-01-13 19:13

    Time for some detective work!

    Looking at the source for event_post in event.c indicates that the C function uses the SDL call SDL_PushEvent, without checking for thread-safety on its own. However, the documentation for SDL_PushEvent says:

    This function is thread safe, and can be called from other threads safely.

    So it seems that it is indeed thread-safe.

    0 讨论(0)
提交回复
热议问题