This is a difficult bug to describe and even harder to reproduce. But it's happening to me.
I have written Python scripts, custom classes, etc. for our site. 99.9% of the time, they run fine. But, every once in a while, while calling a database and transforming the returned dataset into linked custom class objects using a Python script, I get a strange error that is making me think that Ignition is not loading its Python scripts correctly somehow . . . ? Is that even possible?
So far, the error seems to come in two flavors:
It tells me that one of my custom classes, which is a child class of another custom class, cannot be created because the first argument of its init function must be an instance of the parent class. This is nonsense, because this exact same code runs fine 99.9% of the time, and also because the first argument to init is an instance of the parent class (that kind of problem is easily corrected). It's as though, every so often and for no discernable reason, it doesn't understand my class hierarchy even though it had no problem with it literally just a few seconds before. Nothing changed in the interim.
Even stranger, it has started to forget how Python date and timedelta objects work. Again, the code runs just fine almost all the time. But every so often, it throws an error to complain that "+" is not a valid operator between "date" and "timedelta" objects. Now, that's just plain wrong because of course you can add a timedelta to a date, that's the whole point of what a timedelta is. But more importantly, it can't be a syntax issue inside the code because the very same unchanged code runs just fine almost every time it's called. A genuine syntax issue as glaring as using a "+" in the wrong place should happen every time, but it doesn't. It's like the script interpreter on the server has suddenly forgotten how the datetime library works, or failed to load it this time, or . . . . ? I have no idea what's going on.
Reproducing the issue on command is impossible. It does it when it feels like it, and there doesn't seem to be a pattern. It strikes most often on pages which are set up to poll automatically for fresh data, but then again, those are the pages that make the most database calls, so you would expect them to be most vulnerable to odd behavior that strikes when transforming a dataset. It can happen on any page.
My experience as the developer and that of my users (these pages are viewed hundreds of times per day inside our organization) is that closing the tab on their browser and reloading the same page on a fresh tab is usually enough to make the error go away. That implies the users are not doing anything in particular to trigger the problem. In fact, it strikes on pages that load data automatically based on a pre-written named query that takes no parameters, then updates automatically with polling, so the user couldn't possibly be doing anything different when they reload than they did when they got the error. All they did was browse to the page.
And please, no responses about "you need to import datetime" or "you need to rewrite your class init". No I don't. This is not that kind of problem. This problem sometimes happens and sometimes doesn't even though the underlying code hasn't changed. It must have something to do with how Ignition is reading that code, not how it's written.
It didn't start throwing these errors until about a month ago. No, I don't know what changed then.
Has anyone else encountered this, or anything like it? Are there logs hidden away somewhere on the server I could look at to see what Ignition was doing when the trouble hit?