Hi, DR0ID,
While it may not be elegant there is nothing syntactically wrong with
what I did in the event loop. :) When the misbehavior is not occurring
there is no problem exiting the program as it is designed.
To get to the bottom of this I think someone with the right skills and
knowledge would have to dig well beneath the Python code. I lack the
requisites, unfortunately.
Gumm
On 6/29/2014 02:10, DR0ID wrote:
On 2014-06-28 19:14, bw wrote:
if e.key == K_ESCAPE:
print(1)
pygame.display.get_init()
print(2)
pygame.display.get_surface()
print(3)
screen.unlock()
print(4)
pygame.display.set_mode((16, 64))
print(5)
pygame.display.flip()
print(6)
pygame.quit()
print(7)
sys.exit()
print(8)
In this sequence it's understood 8 will never be reached. When the
program exits normally 7 is printed and the program terminates. When
the fps gallops away, indicating the problem has occurred, the last
thing printed is always 6 and the program hangs. In all cases the
pygame functions return, except for pygame.quit(). When trying other
exit routines in lieu of pygame.quit() the exiting statement hangs, I
presume because pygame's cleanup is called.
Gumm
On 6/28/2014 05:29, Sam Bull wrote:
On ven, 2014-06-27 at 22:35 -0700, bw wrote:
I attached the small program. I'm curious if anyone can run it and
reproduce the problem. I plan on upgrading Ubuntu soon, when I am
ready
to risk it: maybe the problem will go away. I'll post the outcome--but
I've been too busy to risk the upgrade, so don't hold yer breath. =)
No idea what the problem could be. I can't reproduce it, but also not
getting more than 130 FPS on my old laptop. I'm curious as to exactly
when it crashes though, can you add some print statements to find
exactly where it crashes?
if e.key == K_ESCAPE:
print("Before")
pygame.quit()
print("After Pygame exit")
quit()
print("Never reached")
I'd also experiment with a couple of different exit
functions, to see if
that makes any difference. For example, try removing the pygame.quit()
call (Pygame will exit safely with Python anyway, so it's a redundant
call here), and using sys.exit() instead of the builtin.
Hi
Could it be that quitting pygame while processing the event queue
(well, the if is in the loop where you process the events) isn't that
nice?
Maybe this does not address the actual problem, but might help finding
the problem.
I would prefer something like this (using the pygame.quit *after*
leaving the while loop):
running = True
while running:
...
for event in pygame.event.get():
....
if event.key == K_ESCAPE:
running = False
pygame.quit()
sys.exit()
Also I thought (maybe I'm wrong) that pygame.quit() is registered by
pygame in the 'atexit' module (so no needed to call separately if
quiting the program, of course you need a pygame.quit() if you only
want to quit pygame but keep python running).
I hope that helps
~DR0ID