seller id deadlock and delete elapsed time
This commit is contained in:
parent
95f7d46beb
commit
e5015c2c66
|
|
@ -13,6 +13,7 @@ import (
|
|||
"os"
|
||||
"strconv"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"gorm.io/driver/mysql"
|
||||
|
|
@ -26,9 +27,25 @@ var (
|
|||
families []gm.AttributeFamily
|
||||
sellers = make(map[string]gm.MarketplaceSeller)
|
||||
AttributesMap = make(map[string]gm.Attribute)
|
||||
locker = stateUnlocked
|
||||
)
|
||||
|
||||
const (
|
||||
stateUnlocked uint32 = iota
|
||||
stateLocked
|
||||
)
|
||||
|
||||
func StartImport(w http.ResponseWriter, route *http.Request) {
|
||||
// lock the request
|
||||
if !atomic.CompareAndSwapUint32(&locker, stateUnlocked, stateLocked) {
|
||||
w.WriteHeader(http.StatusTooManyRequests)
|
||||
json.NewEncoder(w).Encode(map[string]string{
|
||||
"msg": "Scraper or Updater in progress!",
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
defer atomic.StoreUint32(&locker, stateUnlocked)
|
||||
start := time.Now()
|
||||
|
||||
r := new(big.Int)
|
||||
|
|
|
|||
Loading…
Reference in New Issue