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

Expose thread IDs to scripting #2026

Closed
Khaos66 opened this issue Dec 26, 2020 · 6 comments · Fixed by godotengine/godot#44732
Closed

Expose thread IDs to scripting #2026

Khaos66 opened this issue Dec 26, 2020 · 6 comments · Fixed by godotengine/godot#44732
Milestone

Comments

@Khaos66
Copy link

Khaos66 commented Dec 26, 2020

Describe the project you are working on

A small network game with multiple threads

Describe the problem or limitation you are having in your project

Logging in multi-threaded environment is difficult.
I want to be able to see which message was posted by which thread.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Allow GDScript to access the current thread ID

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

I prepared the change in my fork:
KhaosCoders/godot-pg2@1feed85

If this enhancement will not be used often, can it be worked around with a few lines of script?

No

Is there a reason why this should be core and not an add-on in the asset library?

Basic functionallity

@Calinou
Copy link
Member

Calinou commented Dec 26, 2020

@Khaos66 Feel free to open a pull request against the master branch for this 🙂

@Calinou Calinou changed the title Forward Thread.ID to GDScript Expose thread IDs to GDScript Dec 26, 2020
@Calinou Calinou changed the title Expose thread IDs to GDScript Expose thread IDs to scripting Dec 26, 2020
@jonbonazza
Copy link

I mean i dont see any harm in this and implementation should be simple enough to go straight to PR, but im not sure how hav8ng the thread id in your logs is really that useful. You'll usually be viewing your logs in some sort of dashboard and often times long after the thread has already finished, or even after the application has completely restarted which is arguably worse since now you have multiple threads with the same id).

What's your overall goal with this?

@Khaos66
Copy link
Author

Khaos66 commented Dec 27, 2020

@jonbonazza The goal is to be able to group log messages by thread. As each thread has its own state. The thread ID is the most basic method to find all messages that belong together. I'm open for other options ;)
Also, I use this primarily while developing right now. Sure, later the logs are less critical. But finding bugs in a multithreaded environment is hard sometimes and beeing able to tell the states of each thread appart can help.

@Khaos66
Copy link
Author

Khaos66 commented Dec 27, 2020

@Calinou Sadly, I'm not really good at using GitHub and PRs... It seems I have other changes in my fork and each time I create a PR all the other changes are included... I'm sure there is a way to solve this, that I'm not aware of rn.

@Khaos66
Copy link
Author

Khaos66 commented Dec 27, 2020

@Calinou Thank you for the PR =)
I guess this issue is closed then

@Khaos66 Khaos66 closed this as completed Dec 27, 2020
@Jummit
Copy link

Jummit commented Dec 27, 2020

@Khaos66 the proposal should stay open until the PR is merged.

@Calinou Calinou reopened this Dec 27, 2020
@akien-mga akien-mga added this to the 4.0 milestone Jan 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants