Overall this is quite a nice module. Here are a few usability issues/nitpicks, though:
When running the script, there is no easy way to stop it. CTRL+C does not work, I have to manually kill the process. This is probably because of how
threading.Thread
handles it, but I'm not sure.It would be nice if it was slightly easier to add a different handler than the tweeter. For example, I might want to send myself an email, instead of tweeting it right away. To fix this, you should remove all mentions of tweeting from the
SpeedTestThread
class and maybe define a generalEventHandler
class, from whichTwitterThread
derives, which calls some methodaction(self, up, down)
which needs to be defined in the derived class. This way you can easily define aMailThread(EventHandler)
with a differentaction
method that sends a mail instead.You are mixing two variable naming styles,
camelCase
andlower_case_with_underscores
. Python's official style-guide, PEP8, recommends sticking to the latter for all variables and functions/methods. Global constants should be inUPPER_CASE
.For flags you should just use
True
andFalse
, it is a bit easier to read. NotNote that you can dowhile not exitFlag:
instead ofwhile True: if exitFlag == 1: break
andif prevError
instead ofif prevError == 1
.You never increase your
error_logger.counter
, it should beif prevError: self.error_logger.counter += 1 else: self.error_logger.counter = 0
.