Skip to content

Please return thread from start_http_server #883

Closed

Description

@lukeyeager

Similar to #314, but less invasive, IMHO.

I often wrap APIs with a small layer of Python to turn metrics into something that Prometheus can ingest. Rather than adding while True: sleep(1) or similar at the end of my scripts I would like to do this:

prometheus_client.REGISTRY.register(MyCollector())
thread = prometheus_client.start_http_server(80)
thread.join()

Activity

  1. changed the title [-]Return thread from start_http_server[/-] [+]Please return thread from start_http_server[/+] on Jan 23, 2023
  2. csmarchbanks commented on Jan 23, 2023

    @csmarchbanks
    Member

    I think I would be ok with this but will give a bit of time for others to chime in as well. My only initial concern would be that it would make it a bit harder to change an internal implementation, but that is fairly minor.

  3. hholst80 commented on Jan 29, 2023

    @hholst80

    I was thinking about this. How do I shut down the serving component? I guess I don't and just shutdown the application.

  4. csmarchbanks commented on Feb 7, 2023

    @csmarchbanks
    Member

    Correct, start_http_server is designed to be as simple as possible for use cases such as a lightweight exporter. If additional functionality is required it is encouraged to use a different server.

  5. hholst80 commented on Feb 8, 2023

    @hholst80

    I am in favor of a way to control with the thing created. Having a start_http_server not returning a handle is like a copy command that copies files but doesn't tell you where it put the file copy and now it's a game of hide and seek. ;-)

  6. andy-maier commented on Nov 28, 2023

    @andy-maier
    Contributor

    We would also like to have that, see issue #983.

  7. csmarchbanks commented on Jan 25, 2024

    @csmarchbanks
    Member

    #999 will implement this. It returns the server as well as the thread to allow shutdowns, happy to hear any comments about that and will otherwise merge it soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions