Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"event post blocked" when music finishes playing #34

Closed
talljosh opened this issue Dec 4, 2015 · 4 comments
Closed

"event post blocked" when music finishes playing #34

talljosh opened this issue Dec 4, 2015 · 4 comments

Comments

@talljosh
Copy link

talljosh commented Dec 4, 2015

My game uses pygame.mixer.music.set_endevent() to register an event type to be used when music playback is complete. Running my game with pygame_cffi and PyPy, the following traceback was logged when the queued music file finished playing, and the registered event was never observed. I don't get this traceback with standard pygame in cPython.

Traceback (most recent call last):
  File "/home/josh/.local/lib/pypy2.7/site-packages/pygame/mixer_music.py", line 207, in _endmusic_callback
    event.post(event.Event(_endmusic_event))
  File "/home/josh/.local/lib/pypy2.7/site-packages/pygame/event.py", line 226, in post
    raise RuntimeError("event post blocked for %s" % event_name(event.type))
RuntimeError: event post blocked for Unknown
@drnlm
Copy link
Member

drnlm commented Dec 4, 2015

Thanks for the bug report.

Part of the problem is obvious: We shouldn't be raising an exception here - that part of the code should simply drop the event and return to match pygame's behaviour.

However, we should only hit this exception if the event has been blocked explicity. Given that you're expecting to see the event, it sounds like that isn't the case, which suggests that we're incorrectly blocking events under some circumstances. Could you confirm that you're not blocking the event anywhere?

@talljosh
Copy link
Author

talljosh commented Dec 5, 2015

I'm not blocking any events anywhere in my code. However, I am using an event number that doesn't correspond to an actual pygame event type. I'm using 234. I guess it's possible that pygame_cffi's default is to only allow "real" event numbers.

@drnlm
Copy link
Member

drnlm commented Dec 8, 2015

It turns out that, unlike pygame_cffi, pygame doesn't use event.post to add the event to the SDL stack in this case. Consequently, a lot of the checking on the event type is skipped, which is why this works in pygame. While I'd prefer not to have this quirk, if people are relying on pygame's behaviour here, we should probably adjust our implementation to match.

@drnlm
Copy link
Member

drnlm commented Dec 9, 2015

Fixed by #36

@drnlm drnlm closed this as completed Dec 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants