gety
gety

Reputation: 5

Process finished with exit code -1073740791 (0xC0000409) without any reports

The program is based on PyQt5 and python 3.9 and it receives data from server. The program sends request of data to server with QEventLoop.exec_() till receving data is done. The server send data to the program. After receiving all data the QEventLoop.exit() is called.

There are many downloading items.

The error(1073740791 (0xC0000409)) randomly occurs among many items.

If there are 1000 items, the error somtime occur at front, middle or end item. Even the error sometime doesn't occur.

The part of requesting data is...

def day_kiwoom_db(self, code=None, date=None, sPrevNext="0"):
    QTest.qWait(3600)

    self.temp_screen1 += 1
    if self.temp_screen1 >= 150:
        self.temp_screen1 = 0
        self.temp_screen3 += 1

    self.dynamicCall("SetInputValue(QString, QString)", "종목코드", code)
    self.dynamicCall("SetInputValue(QString, QString)", "수정주가구분", "1")

    if date != None:
        self.dynamicCall("SetInputValue(QString, QString)", "기준일자", date)

    self.dynamicCall("CommRqData(QString, QString, int, QString)", "주식일봉차트조회", "opt10081", sPrevNext, "%s" % (int(self.screen_calculation_stock) + self.temp_screen3))

    self.calculator_event_loop.exec_()

The part of receiving data is...

def trdata_slot(self, sScrNo, sRQName, sTrCode, sRecordName, sPrevNext):

    if sRQName == "주식일봉차트조회":
        code = self.dynamicCall("GetCommData(QString, QString, int, QString)", sTrCode, sRQName, 0, "종목코드")
        code = code.strip()


        cnt = self.dynamicCall("GetRepeatCnt(QString, QString)", sTrCode, sRQName)


        for i in range(cnt):
            close_price = self.dynamicCall("GetCommData(QString, QString, int, QString)", sTrCode, sRQName, i, "현재가") 
            close_price = close_price.strip().lstrip('+').lstrip('-')

            value = self.dynamicCall("GetCommData(QString, QString, int, QString)", sTrCode, sRQName, i, "거래량")  
        value = value.strip()

            trading_value = self.dynamicCall("GetCommData(QString, QString, int, QString)", sTrCode, sRQName, i, "거래대금")  # 출력 : 000070
        trading_value = trading_value.strip()

            date = self.dynamicCall("GetCommData(QString, QString, int, QString)", sTrCode, sRQName, i, "일자")  
            date = date.strip()

            start_price = self.dynamicCall("GetCommData(QString, QString, int, QString)", sTrCode, sRQName, i, "시가")  # 출력 : 000070
            start_price = start_price.strip().lstrip('+').lstrip('-')

            high_price = self.dynamicCall("GetCommData(QString, QString, int, QString)", sTrCode, sRQName, i, "고가")  # 출력 : 000070
            high_price = high_price.strip().lstrip('+').lstrip('-')

            low_price = self.dynamicCall("GetCommData(QString, QString, int, QString)", sTrCode, sRQName, i, "저가")  # 출력 : 000070
            low_price = low_price.strip().lstrip('+').lstrip('-')

            print("%s,%s,%s,%s,%s,%s\n" % (date, start_price, close_price, high_price, low_price, value))

            f = open(self.datafile_path, "a", encoding="utf8")
            f.write("%s,%s,%s,%s,%s,%s\n" % (date, start_price, close_price, high_price, low_price, value))
            f.close()


        if sPrevNext == "2" and self.chart_req_time > 0:
            self.day_kiwoom_db(code=code, sPrevNext=sPrevNext)
            self.chart_req_time -= 1
        else:
            print("총 일수 %s" % len(self.calcul_data))
            self.chart_req_time = self.chart_req_tmp
            self.calculator_event_loop.exit()

Can you guide me to solve this problem please?

I want any comments or clues to solve this problem.

also I can't check the problem solved realtime, downloading data takes much time till encountering the error.

As additional information, I tried to find where the error occurs by spreading print("AA"), print("BB"), .... The predicted position of error was at f.write(). I don't know how to solve this problem yet.

Frequent open-close of files may crush selves?

Upvotes: 0

Views: 137

Answers (1)

Rahman Tavakoli
Rahman Tavakoli

Reputation: 63

i suggest to use try and except to log the error.

Upvotes: 1

Related Questions