update process
This commit is contained in:
+3
-4
@@ -108,15 +108,13 @@ func LoadUnprocessed() {
|
||||
err := rows.Scan(&t.id, &t.text)
|
||||
checkDbErr(err, "error in scan telegram")
|
||||
if WriteToClient(t.text) == nil {
|
||||
processed(t)
|
||||
processed(db, t)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func processed(t telegram) {
|
||||
db := getDb()
|
||||
log.Println("get lock")
|
||||
func processed(db *sql.DB, t telegram) {
|
||||
getWriteLock()
|
||||
stmt, _ := db.Prepare(update)
|
||||
result, err := stmt.Exec(t.id)
|
||||
@@ -140,6 +138,7 @@ func countTelegram() int64 {
|
||||
|
||||
func getWriteLock() {
|
||||
count := 0
|
||||
log.Println("write lock :", isWriting)
|
||||
for isWriting && count < 10 {
|
||||
log.Println("waiting for write ")
|
||||
time.Sleep(5 * time.Second)
|
||||
|
||||
Reference in New Issue
Block a user