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

Processes never end #41

Open
SegFault42 opened this issue Mar 30, 2024 · 3 comments
Open

Processes never end #41

SegFault42 opened this issue Mar 30, 2024 · 3 comments

Comments

@SegFault42
Copy link

I've added this code to launch from my frontend


func worker(category, city, userResult, sec string, w http.ResponseWriter) {
if err := run(category, city, userResult+"/"+sec+".json"); err != nil {
		fmt.Println("Oops:")
		os.Stderr.WriteString(err.Error() + "\n")
	} else {
		fmt.Println("Else!")
		fmt.Fprintf(w, "event: close\n\n")
		w.(http.Flusher).Flush()
		fmt.Println("Closed")
		// panic("error")
		//saveSearchToFireStore(userResult+"/"+sec+".json", email, documentName)
	}
}

http.HandleFunc("/api/google-search", func(w http.ResponseWriter, r *http.Request) {

        //code to get parameters
	worker(category, city, userResult, sec, w,)
}

Everything is working well but for some reasons, I have 5 subprocesses that never end when the search is done.

Screenshot 2024-03-30 at 10 36 24

Any idea how I can end those processes ?

@gosom
Copy link
Owner

gosom commented Apr 18, 2024

I assume your run function does the initialization of the app etc.

pass the request context there and once this context is done the processes should be cleaned up

@gosom
Copy link
Owner

gosom commented May 20, 2024

@SegFault42 did my recommendation fixed your issue?

@SegFault42
Copy link
Author

SegFault42 commented May 22, 2024

No didn't really understand

This is my run function

Screenshot 2024-05-22 at 13 35 56

It just create the ctx and then run the runFromLocalFile function

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

No branches or pull requests

2 participants