Doing a little better today, but still feel like I'm
moving at one-quarter speed, on account of not having
been able to stay asleep long enough at a time, last night.
Still have way too much to do and fearing too little time
to do it in, but this morning I finally knocked off one
item I'd been stressing about ...
The automatic QotD-posting script[0] was a little fragile,
in that if any one site it was trying to crosspost to was
down or really glitchy, the script would get stuck trying
and retrying to post to that site and not get to any of
the ones later on its list. When this means I have to go
thump it by hand when I wake up and the QotD is merely a
few hours late some places, that's just a small annoyance.
But I didn't want to leave it vulnerable to that problem
while I run off to Pennsic, as I won't be logging in all
that often and the state of the queue could get rather
messed up if the problem were to occur and persist for a
few days. So when I woke up this morning after my two hour
sleep (*grrr* It wasn't even two solid hours,
as odd dreams and odd pains took turns interrupting)
and I didn't really feel like I could move much with the
way my arms and shoulders hurt, I figured it was time to
start banging out code.
The new version is probably more complicated than it
should be -- I'm considering it the first draft of the new
approach, and if I wind up throwing it away and starting
over sometime in August, no biggie -- but in my tests so
far it does seem to be working. It fires up several
background processes, and each of those does the "try to
post, retry if Clive (the client I hacked) returns an error
code" loop on its own at the same time as each other; I also
made the timeout incremental (well, geometric actually)
because my old wait-two-minutes thing was kinda stupid.
(I'd coded the two-minute timeout when most of the errors
I saw were brief connectivity glitches and cosmic-ray errors,
and a few quick retries usually sufficed, but every so often
a site goes offline -- or is still present but broken -- for
a few hours or a couple of days, which means that I get
a womdigious email message from the cron daemon,
full of "failed, trying again" messages, when the problem
finally gets fixed or I kill the process by hand, and I'm
tying up more resources on the machine where it runs than
really do any good (probably not enough for the admins to
get annoyed, but it still feels wrong. So now it starts
at two minutes and the delay is multiplied by the square
root of two each time it fails, so one-time glitches and
fairly brief site outages will still result in a successful
retry after a very short time, and when a site does down for
eighteen to fifty hours, my program will back off to a more
reasonable interval instead of banging on the door constantly
screaming, "Let me in!" But I should probably put a cap on
the delay, and I do need to go fix a bug (or just
a missing feature, depending on how you look at it) in Clive,
where if the next day's quote does get posted during the
previous day's wait-to-retry delay, the one that got delayed
won't get posted at all[1]. But even if I don't fix that
before I leave for Pennsic, it'll only affect one site at a
time, rather than screwing up all of the copies of my journal.)
Anywho, the reason I'm bothering to tell all y'all this[2]
is that despite the tests I've just finished running, there's
always the chance that I've overlooked some condition that will
bite me come 5:25 tomorrow morning. So if tomorrow's QotD
doesn't show up on time, or the same quote shows up two days
in a row, it's probably because I need to polish the new
autoposter.
I've had a bunch of really cool ideas for it in my head for
a while, but most of them will have to wait. This change is
less nifty, but was something I really wanted to have
in place before Pennsic.
[0] Uh, I'm pretty sure most of you have either
already heard me talk about this or figured it seemed obvious
from the usually-consistent posting times, but every so often
I'm reminded that it's not something non-geeks automatically
think of as a candidate for automation. Anyhow, sometimes I
have two or three days worth of quotes already lined up in the
queue, and other times I have two or three months worth set up
and ready to go. And the cron daemon is my friend. Someday
in the (very distant, I hope) future, this may wind up being
a little creepy and upsetting for the rest of you, but until
then it's a signficiant convenience.
[1] The problem is that LJ et.al. don't appear to
let you just post a backdated entry if a later entry already exists,
unless you set a "yes I really mean to do this" bit someplace
(the "date out of order" flag), and (as of the version I've got
which I think is current) Clive doesn't appear to have any way
of setting that bit. So I need to go read up on the LJ API,
to learn how it's supposed to be done, and then find the right
spot (in a different section of the code than I've been tinkering
with so far) to hack Clive to do the right thing. Either that,
or give up on trying to backdate delayed posts -- which would
mean that different mirrors of my journal would have entries
in different orders.
[2] OMG, I must be even more tired than I realized,
if I'm thinking in a dialect which uses a singular
"y'all" (thus requiring "all y'all" as the plural) -- Sheepie
has pointed out (and I think
realinterrobang
has done so as well) that the more tired I am, the more Southern
my accent gets, but "all y'all" isn't even my own dialect.
(It's a near enough neighbour that I'm used to hearing it, but
it's not one I normally speak ... uh, I think.)