xloil
xloil copied to clipboard
COM Error 0x800ac472: Unknown error 0x800AC472
I have implemented an RTD function that consumes data from a kafka topic and streams this data to excel. My RTD function is provided below.
import json
import asyncio
import datetime
import xloil
import xloil.pandas
import xlwings as xw
import pandas as pd
import numpy as np
from config import Config
from aiokafka import AIOKafkaConsumer
_rtdServer = xloil.RtdServer()
@xloil.func
def subscribe():
'''
Main User Defined Function for subscribing to kafka consumer.
'''
async def fetch() -> float:
while True:
try:
# Initialize kafka consumer.
consumer = AIOKafkaConsumer('TopicName',
value_deserializer=lambda m: json.loads(m.decode('utf-8')),
bootstrap_servers=Config.kafka_socket)
await consumer.start()
async for msg in consumer:
data = msg.value
yield float(data['values']['value'])
except Exception as e:
print(f"Error in kafka consumer: {e}")
asyncio.sleep(2)
finally:
await consumer.stop()
return xloil.rtd.subscribe(_rtdServer, "rtd_subscription", fetch)
I have a problem where the rtd function stops updating data in excel. And excel has to be restarted to be able to automatically update data again (Resubscribing by deleting function does not work. A full restart of excel is the only thing working).
I get the following error in the logs (Unsure if it is related to the above mentioned problem): [2023-08-03 08:39:39.958] [logger] [error] [ComEventSink.cpp:338] COM Error 0x800ac472: Unknown error 0x800AC472
What could be the cause of this behaviour?
This is a tricky one, the error you're getting is the 'dreaded' VBA_E_IGNORE which Excel issues when the COM interface is busy (usually a dialog box open or similar) however it seems to be getting into a broken state some other way. I've not been able to replicate the issue, but I've made a couple of changes which may help in 0.17.13 which I released this week. If you can test and let me know that would be great. From your side it's also worth checking that things aren't getting stuck
in the Kafka connection by putting in a timeout (unless there is a default one or it's configured elsewhere?)
Closing due to lack of response