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

Implementation of Single Thread Mode #88

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

itsuwari
Copy link

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

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
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
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