Re: Socket code not executing properly in a thread (Windows)
John Nagle na...@animats.com wrote in message news:jta1v7$v0b$1...@dont-email.me... We have no idea what IRC module you're using. I am sending plain text to the socket, sorry for not mentioning it before. At the simplest level, it appears that when the code runs in Windows, data is not sent to a socket when inside a thread, while on OS X it is. Also, running the sned to socket code inside the main loop would not work, as the main loop pauses until it recieves data from the socket (an IRC message), which is why I didn't put the SMS code in the main loop in the first place. The Google Voice code you have probably won't work once you have enough messages stored that Google Voice returns them on multiple pages. I know that this is not the problem because the code works fine on OS X, but not Windows, where I actually need it to run. In addition, each message is deleted as it is parsed and no other SMSs are sent to the number, so fill-up should not be a problem. -- http://mail.python.org/mailman/listinfo/python-list
Re: Socket code not executing properly in a thread (Windows)
On 07/08/2012 11:03 AM, Andrew D'Angelo wrote: Also, running the sned to socket code inside the main loop would not work, as the main loop pauses until it recieves data from the socket (an IRC message), which is why I didn't put the SMS code in the main loop in the first place. http://docs.python.org/library/select.html -- http://mail.python.org/mailman/listinfo/python-list
Socket code not executing properly in a thread (Windows)
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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Socket code not executing properly in a thread (Windows)
On 07/08/2012 12:55 PM, Andrew D'Angelo wrote: Please set your clock to the correct date and time. (If it would help, the full code can be seen here: http://lickitung.it.cx/exe/bot/bot.py): No, it can't. def sendPrivateMessage(channel, message):#private message send function global mute if mute == 0: IRC.send(PRIVMSG + channel + : + message + \r\n) #IRC being the socket Do you have an error message or something? Without knowing more about the IRC library you're using, it's hard to say what the reason behind the platform-dependent behaviour is. However, it's clear that you should be calling IRC.send from the main thread. That shouldn't be too hard to achieve, save the message to some sort of event or outgoing message queue that the main thread processes in sequence. (This sounds to me like an application better implemented thread-less, using select() or some method of asynchronous I/O. Just a shame that Python makes neither at all pleasant and leaves threads as the nicest option) Thomas -- http://mail.python.org/mailman/listinfo/python-list
Re: Socket code not executing properly in a thread (Windows)
Thomas Jollans t...@jollybox.de wrote in message news:mailman.1895.1341677582.4697.python-l...@python.org... On 07/08/2012 12:55 PM, Andrew D'Angelo wrote: Please set your clock to the correct date and time. My BIOS battery has died and I haven't gotten a chance to replace it. Made a mistake when setting the date on boot-up. :-\ Do you have an error message or something? No, it simply does not send the message. Without knowing more about the IRC library you're using I am sending plain text to the socket, without a library. However, it's clear that you should be calling IRC.send from the main thread. That shouldn't be too hard to achieve, save the message to some sort of event or outgoing message queue that the main thread processes in sequence. Good idea, thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Socket code not executing properly in a thread (Windows)
On 7/8/2012 3:55 AM, Andrew D'Angelo wrote: Hi, I've been writing an IRC chatbot that an relay messages it receives as an SMS. We have no idea what IRC module you're using. As it stands, I can retrieve and parse SMSs from Google Voice perfectly The Google Voice code you have probably won't work once you have enough messages stored that Google Voice returns them on multiple pages. You have to read all the pages. If there's any significant amount of traffic, the completed messages have to be moved or deleted, or each polling cycle returns more data than the last one. Google Voice isn't a very good SMS gateway. I used to use it, but switched to Twilio (which costs, but works) two years ago. John Nagle -- http://mail.python.org/mailman/listinfo/python-list
socket code
Hello, I'm trying to create a broadcast socket in some portable code (windows XP mandrake linux). When I run the following lines through idle: import socket s = socket.socket( socket.AF_INET, socket.SOCK_DGRAM ) s.connect( ('broadcast', 17100) ) On windows, connect() returns and I have a broadcast socket to which I can write. One LINUX connect() just tells me 'Permission denied'. Does anybody know why? Any thoughts on how I can get around this? I have to transmitt data to an old system. The system only reads broadcast data on port 17100. Thanks for the input. Ron Provost -- http://mail.python.org/mailman/listinfo/python-list
Re: socket code
On 2005-07-08, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hello, I'm trying to create a broadcast socket in some portable code (windows XP mandrake linux). When I run the following lines through idle: import socket s = socket.socket( socket.AF_INET, socket.SOCK_DGRAM ) s.connect( ('broadcast', 17100) ) On windows, connect() returns and I have a broadcast socket to which I can write. One LINUX connect() just tells me 'Permission denied'. Does anybody know why? Any thoughts on how I can get around this? I have to transmitt data to an old system. The system only reads broadcast data on port 17100. Didn't we just answer this question for you two weeks ago? http://groups-beta.google.com/group/comp.lang.python/browse_frm/thread/6447ef29cf613660/dcdc52690aa562e1 -- Grant Edwards grante Yow! I'm RELIGIOUS!! I at love a man with a visi.comHAIRPIECE!! Equip me with MISSILES!! -- http://mail.python.org/mailman/listinfo/python-list