Skip to content
This repository was archived by the owner on Aug 10, 2023. It is now read-only.

Implementation of Single Thread Mode#88

Open
itsuwari wants to merge 3 commits into
acheong08:masterfrom
itsuwari:master
Open

Implementation of Single Thread Mode#88
itsuwari wants to merge 3 commits into
acheong08:masterfrom
itsuwari:master

Conversation

@itsuwari

Copy link
Copy Markdown

When SINGLE_THREAD is "yes", a .lock file is created, managing request flow to prevent 429 error from multiple simultaneous requests.

Comment thread handlers.go
Comment on lines +92 to +107
func LockFileMiddleware(c *gin.Context) {
// Check if SINGLE_THREAD is set to "yes"
if os.Getenv("SINGLE_THREAD") == "yes" {
// If yes, check for the existence of the lock file
for {
_, err := os.Stat(".lock")
if os.IsNotExist(err) {
break
}
// If the lock file exists, wait for 0.5 seconds before checking again
time.Sleep(500 * time.Millisecond)
}
}
c.Next()
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't account for multiple accounts

@acheong08

Copy link
Copy Markdown
Owner

hash of access token .lock to prevent multithread for any account but still takes advantage of multiple account would be better

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants