I currently have some of my google voice scripts running once every 5 minutes to avoid overlap. My processing script and sending script will both be fine if multiple instances run, due to the tracking system I’ve developed on the database, but I worry about the script that actually fetches the incoming messages from Google Voice. Duplicate instances of that script may cause messages to be fetched twice, and I have yet to write a script to check for duplicate incoming messages. I might as well make an effort to kill some of the duplicates at the source first.
Here is the function:
# check_if_running.py import os import commands import sys def checkRunning(): # ps -ef | grep | grep -v grep | grep -v psCommand = "ps -ef | grep "+str(sys.argv)+" | grep -v grep | grep -v "+str(os.getpid()) psOutput = commands.getoutput(psCommand) if (len(psOutput) == 0): functionReturn = 0 else: functionReturn = 1 return functionReturn print "Function returns: "+str(checkRunning()) exit()
Speaking of duplicates, I have noticed that some outgoing messages are sent multiple times. My theory is that the phone is actually sending duplicate messages in low signal areas when it cannot be certain if the message has been sent or not, therefore still necessitating the duplicate checking script even if it just just a secondary check on the existing processes.
PS: This is an example of a new-to-me wordpress plugin, WP-Syntax. Pretty slick? Yes, I think it is.