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

How to execute simultaneously #1430

Open
txf1p opened this issue Jan 31, 2024 · 0 comments
Open

How to execute simultaneously #1430

txf1p opened this issue Jan 31, 2024 · 0 comments

Comments

@txf1p
Copy link

txf1p commented Jan 31, 2024

func (s *session) SendMessage(_ context.Context) {
	var wg sync.WaitGroup
	for n, _ := range numbers {
		wg.Add(1)
		go func(n string) {
			defer wg.Done()
			flag := true
			ctx, cancel := chromedp.NewContext(s.ctx)
			defer cancel()
			if err := chromedp.Run(
				ctx,
				....................
			); err != nil {
				flag = false
			}
		}(n)
	}
	wg.Wait()
	return
}

s.ctx has completed the login. Now I want each coroutine to perform the same operation (open many new windows for execution),

Opening the current code will cause the newly opened page to be about:blank. If you use s.ctx directly, you will operate on the same page.

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

1 participant