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

Game hangs, and will not exit. #11

Open
otzen opened this issue Dec 5, 2021 · 2 comments
Open

Game hangs, and will not exit. #11

otzen opened this issue Dec 5, 2021 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@otzen
Copy link

otzen commented Dec 5, 2021

There was a bug that caused the process to hang.
To reproduce:
Follow step 2 to 5 in the Readme
2. python3
3. import ironSeed
4. game = ironSeed.IronSeed()
5. Now wait until the initialisation is finished

Now try and exit.... you cannot, you need to kill the process with kill -9

My OS: Linux (Debian Sid)

It was hard to debug as the program apparently ran to end, I tried adding a final print statement, and it was printed fine. So the process should exit. But it did not.

I early on suspected some background task of pygame to be the culprit.

I narrowed the cause it down to the pygame.init being called multiply times. This happens because there is a call to this pygame.init function in the root scope of global_constants.py, causing this function to be called each time this file is imported by any other file.
I also found that this error was not consistent, some times it would exit fine with no delay and other times just hang. I also found that if commented out some of the imports, that also imported global_constants, thereby reducing the number of times that pygame.init was called, I saw a drop in the number times it would hang, confirming my suspicion that this was triggering some race condition in the pygame background tasks.

Solution: I moved the initialization of the non-primitive types inside an init function, including this call to pygame,init(). So now the pygame.init() is only called when this function is explicitly called. Also added the call to this init() to ironSeed.py.

Note: I had to inject the h.IronSeedTime object through this call to, as calling it directly from within globals would not work as it would create a circular import loop.

@otzen otzen added the bug Something isn't working label Dec 5, 2021
@otzen
Copy link
Author

otzen commented Dec 5, 2021

Probably fixed by #10

@otzen otzen mentioned this issue Dec 5, 2021
@nukebloodaxe
Copy link
Owner

I'm addressing this in the intialization screen branch, where I'm writing a proper loading screen. Your suggestions provided me with some inspiration ;) It also reminded me I currently have time to look at this project again; it's been a horror year, I keep losing my holiday breaks to lockdowns and remote work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants