The Go Programming Language
http://golang.org/
Go Playground
Go Projects
Revel Web Framework
jonathanchoo

Go 的 HTTP 框架中不是用 Goroutine 来处理请求的吗

  •  
  •   jonathanchoo · Dec 29, 2020 · 1853 views
    This topic created in 1965 days ago, the information mentioned may be changed or developed.

    Go 的 HTTP 框架中不是用 Goroutine 来处理请求的吗?

    那在 Handler 中 go 出去的 func,如果不 wait,那作为派生 Goroutine,不会因为 Handler 结束而提前终止吗?

    catror
        1
    catror  
       Dec 29, 2020
    不会,goroutine 是相互独立的
    FinnBai
        2
    FinnBai  
       Dec 29, 2020
    提前终止的情况应该是 main goroutine 终止时才会发生
    jonathanchoo
        3
    jonathanchoo  
    OP
       Dec 29, 2020
    @baiyi
    哦对对,怪不得需要 context 去协调 goroutine 之间的关系

    此贴终结
    ly020044
        4
    ly020044  
       Dec 29, 2020
    Go 的 HTTP 框架是用 Goroutine 来处理请求的。但你在 Handler 中开启的协程不会因为这个请求结束而终止。和 HTTP 使用的 Goroutine 没啥关系
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2871 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 10:33 · PVG 18:33 · LAX 03:33 · JFK 06:33
    ♥ Do have faith in what you're doing.