Socket code not executing properly in a thread (Windows)
Andrew D'Angelo
excel at pharcyde.org
Sun Jul 8 06:55:03 EDT 2012
Hi, I've been writing an IRC chatbot that an relay messages it recieves as
an SMS.
As it stands, I can retrieve and parse SMSs from Google Voice perfectly, and
print them to the console. The problem lies in actually posting the message
to the IRC channel. Since the SMS checker runs in a thread apart from the
regular chatbot duties, the socket communication also takes place in the
thread. Something even stranger is that the code works on OS X, but not on
WIndows, where my server runs. Here is a code snippet (If it would help, the
full code can be seen here: http://lickitung.it.cx/exe/bot/bot.py):
def checkVoice():
global upHz
global CHANNEL
global mute
while 1:
print "Update voice!"
voice.sms()
msgitems = [] #Extract all conversations by searching for a DIV with
an ID at top level.
tree = BeautifulSoup(voice.sms.html)
conversations = tree.findAll("div",attrs={"id" :
True},recursive=False)
#parsing code cut for brevity - I know it works, though
sendPrivateMessage(CHANNEL,message) #as far as I can tell,
this is failing to execute
time.sleep(upHz)
def sendPrivateMessage(channel, message):#private message send function
global mute
if mute == 0:
IRC.send("PRIVMSG " + channel + " :" + message + "\r\n") #IRC being
the socket
More information about the Python-list
mailing list