Windows Process不会跨越s进行通信

2024-09-21 05:49:16 发布

您现在位置:Python中文网/ 问答频道 /正文

我一直在写一个IRC聊天机器人,它检查googlevoice中的短信息,然后通过端口6667上的一个插座将它们转发到聊天室。聊天消息处理在main sub中以无限循环运行,而GV检查则在单独的进程中完成。实际的检查和获取工作正常,但是套接字不工作;没有消息发布到通道。奇怪的是,它在OSX下工作得完美无缺,所以我不认为问题出在语音处理逻辑上:

def checkVoice()
    while 1:
        print "Update voice!"
        #voice processing... edited for brevity
        sendPrivateMessage(CHANNEL,message) #This doesn't work
        #more code
        time.sleep(10)

#main block
if __name__ == '__main__':
    sendPrivateMessage(CHANNEL,"Voice checking started") #This works
    p = Process(target=checkVoice)
    p.start()

我假设问题出在Windows处理Python的方式上,因为它可以处理其他平台。你知道吗

chatbot的完整代码如下: bot.py

如前所述,这里是sendPrivateMessage方法:

def sendPrivateMessage(channel, message):#private message send function
    global mute
    if mute == 0:
            IRC.send("PRIVMSG " + channel + " :" + message + "\r\n")

Tags: send消息messageifmaindefircchannel

热门问题