I'd try to figure out, where those bytes come from. This feels like some memory corruption inside the client and it is unlikely that they came from TWS/IBGW through the socket connection (though not impossible).
The message processing is in the middle of reading the "open" bar field from the historical data bar message. At that point, there should only be 7bit ASCII string values in the message such as the digit characters and other number related characters such as [0-9.+=E] (plus the byte value 0 to indicate the end of each field). There should definitely be no Unicode characters and specifically the "unlimited" sign would be out of place.
A couple things come to mind:
- Just before the first line in your stack trace, IBAPI has a debug statement that dumps all fields in the message. Maybe you can run your client with debug enabled. Seeing all field values when the error occurs might give you a clue as to where the Unicode comes from. I have the suspicion that you'll find more than one character. The debug statement in IBAPI looks like this: logger.debug("fields %s", fields)
- To eliminate TWS/IBGW and the socket from the equation, you could grab a network trace (say tcpdump) of the API connection. It is quite simple to inspect the packets with Wireshark and you'd see exact what came from TWS/IBGW.
闯ü谤驳别苍
?
?
On Thu, Nov 7, 2024 at 07:38 AM, bespalex wrote:
toggle quoted message
Show quoted text
you can catch exceptions in threads without modifying the ibapi source code by using Python's threading.excepthook function
?
On Thu, Nov 7, 2024 at 01:02 AM, Cash wrote:
Using Python api -
?
From time to time i am getting following error and it stops the api thread completely. I can't catch this exception in Main thread. This happens with HistoricalData callback. It is somehow receiving inifinity character as i understand.
Is there a way to catch this exception without updating API source code?
?
? File "xxx/ibapi-10.30.1-py3.9.egg/ibapiibapi/client.py", line 398, in run
? File "xxx/ibapi-10.30.1-py3.9.egg/ibapi/decoder.py", line 1506, in interpret
? File "xxx/ibapi-10.30.1-py3.9.egg/ibapi/decoder.py", line 616, in processHistoricalDataUpdateMsg
? File "xxx/ibapi-10.30.1-py3.9.egg/ibapi/utils.py", line 135, in decode
ValueError: could not convert string to float: b'\xe2\x88\x9e'