Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

avoid name break in chatgpt.SendMessage #106

Merged
merged 2 commits into from
Mar 22, 2023
Merged

Conversation

yuldashboev
Copy link
Contributor

because there is no logic below for loop, we can just return from the function making code clearer.

@yuldashboev
Copy link
Contributor Author

yuldashboev commented Mar 2, 2023

Consider the code below causing data racing because of unprotected conversations map

```

chgpt := chatgpt.Init()

go func() {
	ch, err := chgpt.SendMessage("test-racing", 123456)
	if err != nil {
		panic(err)
	}

	for range ch {
	}
}()

go func() {
	ch, err := chgpt.SendMessage("test-racing", 123457)
	if err != nil {
		panic(err)
	}

	for range ch {
	}
}()

Fixed this data racing by protecting map with mutex.

@m1guelpf m1guelpf enabled auto-merge (squash) March 22, 2023 22:47
@m1guelpf m1guelpf merged commit 7860003 into m1guelpf:main Mar 22, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants