And sorry I got ticked, frustrating week
>And I could help more, being fairly experienced with >threading issues and race conditions and such, but >as I tried to indicate in the first place, you've >provided next to no useful (IMHO) information to >let anyone help you more than this
This is about 5% of the code. Uses no locks. I am mystified, I have written probably 100,000 lines of Python and never seen a thread just lock up and quit running. It happens on a Queue() statement so my suspicion is a bug. ??
I have kludged around it by putting all the thread/queue stuff in the main program and import the stuff I don't want to distribute. But mysteries haunt your dreams, sooo... #!/usr/local/bin/python
# pnetx.py
from threading import * from time import * from Queue import Queue from socket import * import sys import os
# glob is a DUMMY CLASS
glob.listenq = Queue(1000)
def listener(): while 1: msg,addrport = listenersocket.recvfrom(BUFSIZE) addr = addrport[0] glob.listenq.put (( msg,addr),1) if msg == 'DIE': break def procmsgs(): while 1: msg,addr = glob.listenq.get(1) if msg == 'DIE': break wds = msg.split(';') if wds[0] == 'S': recvsucc(msg); continue if wds[0] == 'E': recvevent(msg); continue if wds[0] == 'ACK': recvack(msg[4:]); continue if wds[0] == 'MONITOR': if addr not in monitorlist: print 'This line ALWAYS PRINTS' queuelist.append( Queue(0) ) ## The above fails if this code is imported ## It doesn't matter whether it is imported ## as .py or .pyc ## also mq = Queue(0); queuelist.append(mq) # fails print 'This line ALWAYS PRINTS if i execute this source' print 'but NEVER PRINTS if I import ' print 'this source from a 1 line program' print 'Thats weird' monitoron.append( 1 ) monitorlist.append( addr )
queuelist = [Queue(0)]
listenersocket = socket(AF_INET,SOCK_DGRAM) listenersocket.bind(ListenAddr)
procm = Thread(target=procmsgs) procm.start() listenr = Thread(target=listener) listenr.start()
## Then start a bunch of other threads and queuea.
Don't spend a lot of time on this, not worth it. I just thought someone might have experienced something similar.
-- http://mail.python.org/mailman/listinfo/python-list