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

feat: allow user to safely run and manage multiple progressbar http servers #213

Merged
merged 2 commits into from
Jan 24, 2025

Conversation

cmsax
Copy link

@cmsax cmsax commented Jan 23, 2025

Description:

This PR refactors the HTTP server implementation in the ProgressBar to address issues with the global default HTTP server instance, which caused panics when creating multiple ProgressBar instances with HTTP servers. The changes introduce a dedicated HTTP server instance for each ProgressBar, enabling users to safely run and manage multiple servers.

Key Changes:

Replaced the global http.HandleFunc with isolated http.ServeMux instances per ProgressBar.

Added a new HTTPServer object returned by StartHTTPServer(), providing a Shutdown() method for graceful termination.

Benefits:

Prevents route conflicts between multiple ProgressBar instances.

Allows users to start and stop HTTP servers independently.

Ensures safer concurrent usage and better resource management.

@cmsax cmsax changed the title feat: allow user to shutdown progressbar http server instance feat: allow user to safely run and manage multiple progressbar http servers Jan 23, 2025
@schollz schollz merged commit 2236360 into schollz:main Jan 24, 2025
1 check passed
@schollz
Copy link
Owner

schollz commented Jan 24, 2025

Great work, thanks!

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

Successfully merging this pull request may close these issues.

None yet

2 participants