QNetworkAcessManager | QThread::start: Failed to create thread
-
Hello guys, i am having a a problem when i get content of json files from one page, i receive this error QThread::start: Failed to create thread (Código de acesso inválido.)
how to solve this?
my request codes:
void Parser::steamRequest() { QNetworkAccessManager * nan = new QNetworkAccessManager(this); ui->editGamesLogs->clear(); QString key = ui->edit_key->text(); league_id = 0; if(!vectorLeagues_id.isEmpty()){ league_id = vectorLeagues_id[0]; vectorLeagues_id.pop_front(); } qDebug() << "FROM STEAM REQUEST LEAGUE ID: " << league_id << " Vector size" << vectorLeagues_id.size(); if(league_id >= 1){ QString urlSteam = "https://api.steampowered.com/IDOTA2Match_570/GetMatchHistory/v1/?key="+key+"&league_id="+QString::number(league_id,'.',0)+""; QUrl url(urlSteam); qDebug() << url.url() << urlSteam; connect(nan,SIGNAL(finished(QNetworkReply*)),this,SLOT(steamParser(QNetworkReply*))); nan->get(QNetworkRequest(url)); } } void Parser::trackDotaRequest() { QNetworkAccessManager * nan1 = new QNetworkAccessManager(this); direPlayers.clear(); radiantPlayers.clear(); actionsRecord.clear(); infosGeral.clear(); match_id = 0; query = Connection::getQueryInstance(); query.prepare("SELECT match_id FROM partida WHERE isTracked=0 and league_id=:league_id"); query.bindValue(":league_id", league_id); query.exec(); if(!query.next()){ steamRequest(); }else{ match_id = query.value(0).toDouble(); } Connection::getInstance(false); if(match_id >= 1){ QString urlSteam; urlSteam = "http://www.trackdota.com/data/game/"+QString::number(match_id,'.',0)+"/live.json"; QUrl url(urlSteam); ui->editGamesLogs->append("TrackDota Match ID" +QString::number(match_id,'.',0)+" está sendo carregado!"); connect(nan1,SIGNAL(finished(QNetworkReply*)),this,SLOT(gameParser(QNetworkReply*))); nan1->get(QNetworkRequest(url)); } } -
Hi,
Why are you creating one QNetworkAccessManager per query ? Use only one as class member and then avoid creating so many QNAM. The base class can handle multiple calls up to 6 in parallels and then it cues them.
-
How fast are you creating the request ?
What is that parser class ? -
i remake all the project, see this code
my function to call this code
void Parser::getSteamInformations() { if(contador == 0){ query = Connection::getQueryInstance(); vectorLeagues.clear(); if(query.exec("SELECT league_id FROM leagues_id")){ while(query.next()){ if(query.value(0).toDouble() > 0) vectorLeagues.push_back(query.value(0).toDouble()); } } else qDebug() << query.lastError().text(); contador++; Connection::getInstance(false); } if(vectorLeagues.size() > 0){ double value = vectorLeagues[0]; vectorLeagues.pop_front(); qDebug() << "GetSteamInformations iniciara " << value; steamSlots->steamRequest("XXXXXXXXXXXXXXXXXXXXXXX", value); } }but when i try to get my list of 340 leagues, it stop and no go forward
i need delete nam in every call? how to clear the nam, from the next requisition after my emit?
[edit: removed ID SGaist]
-
It's surprising your code doesn't crash. You are making your
namvariable a null pointer just before using it. Your replies are likely not getting deleted since you connect thefinishedsignal while the reply already finished. You are also connecting theQNetworkAccessManagersignals several times. -
I try put it in practice, but still don't work maybe i am made another mistake, i define nam and the connection in constructor, the first url is parsed sucefull, but the second stop and not go forward...
steam::steam() { max_match_id = 0; min_match_id = 99999999999; nam = new QNetworkAccessManager(); connect(nam,SIGNAL(finished(QNetworkReply*)),this,SLOT(steamParser(QNetworkReply*))); }LOGS: Obtendo informações do League :8 Inclusão no banco de dados concluida! Adicionado 0 registros no banco de dados Obtendo informações do League :27 <-- stop here qDebug() LOGS "https://api.steampowered.com/IDOTA2Match_570/GetMatchHistory/v1/?key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&league_id=8" "https://api.steampowered.com/IDOTA2Match_570/GetMatchHistory/v1/?key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&league_id=8&start_at_match_id=29378911" "Inclusão no banco de dados concluida! Adicionado 0 registros no banco de dados" 343 "https://api.steampowered.com/IDOTA2Match_570/GetMatchHistory/v1/?key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&league_id=27"Thanks alot for u time bro!
[edit: Removed key SGaist]
-
Will you please stop posting your steam key ?
That said, are you sure you're not getting throttled ?
You should also connect the error signals to see what is happening.