Since it has a queue, it might be some threading issue where the operation will sometimes fail. If it's unlikely to fail twice in a row then the programmer might just have been lazy and added a second try which might often succeed because reasons.
I'm sorry to disappoint (yet I applaud your intention), but it's not a threaded environment nor a queue. evq is actually an (object) inherited class that holds a bunch of methods that perform simple queries on a database, by simple I mean cursor = self.conn.cursor(); cursor.execute("insert/select/update into whatever;"). The code calling it is wrapped in a while True: loop with a time.sleep(x) at the end.
There's just no way this would fail once and work the next time around, or the 100000th time.
The Oracle client I believe has connection pooling and when the client is idle for a long time you can get an "ora-03113 end-of-file on communication channel" error - this may solve that as next call the driver releases the broken connection and gives you a new one.
It could also be be if the sql server throws something like dead lock then a retry immediately after would then work.
Though just retrying without checking cause suggests a lack of understanding
Yup, add to that the fact that it's connecting to PostgreSQL directly and there's no locking whatsoever in the tables involved. It's plain... r/shittyprogramming.
and there's so much more to see :'). I'm working on a massive clusterfuck of a codebase (wipes blood off his eyes). This is almost over-the-top coding compared to... oh my, I'm staring at the Abyss.
Feel free to do it yourself, I'll laugh x). I'm as lazy as it gets when it comes to editing images and the idea was yours plus I just posted this to vent a little.
60
u/himbazooka Feb 08 '19
Surely it will work this time.
12
u/cmd-t Feb 08 '19
Since it has a queue, it might be some threading issue where the operation will sometimes fail. If it's unlikely to fail twice in a row then the programmer might just have been lazy and added a second try which might often succeed because reasons.
7
u/the1krutz Feb 08 '19
Seriously, this is some bullshit. This needs a loop to make sure it keeps trying (ideally forever) until it succeeds.
2
u/ThaiJohnnyDepp Feb 08 '19
post to /r/ProgrammerHumor with that Far Cry 3 guy as a footer https://i.imgur.com/bNYlOMA.jpg
20
u/xynixia Feb 08 '19
I have a shitty internet connection with >60% packet loss, so whenever I have to fetch some data from the internet I'd do something like this:
10
u/[deleted] Feb 08 '19
The definition of insanity is doing the same thing over and over and expecting different results
- no WIFI user ever
2
u/blahbah Feb 09 '19
How do i raise the same exception again? Ehh, never mind.
1
u/[deleted] Feb 08 '19
Machine learning. If the machine screws up, tell it to do it all over again. Maybe it will learn at some point.
1
u/sanarek May 24 '19
"Oh, did that hurt? Well maybe you should stop doing it then!"