Problem with multithreading
Lou Pecora
pecora at anvil.nrl.navy.mil
Thu Jun 25 14:20:33 EDT 2009
In article <h20d7k$nih$03$1 at news.t-online.com>,
"larudwer" <larudwer at freenet.de> wrote:
> "Jeffrey Barish" <jeff_barish at earthlink.net> schrieb im Newsbeitrag
> news:mailman.2091.1245902997.8015.python-list at python.org...
> > Jeffrey Barish wrote:
> >
> >> I have a program that uses multithreading to monitor two loops. When
> >> something happens in loop1, it sends a message to loop2 to have it
> >> execute
> >> a command. loop2 might have to return a result. If it does, it puts the
> >> result in a queue. loop1, meanwhile, would have blocked waiting for
> >> something to appear in the queue. The program works for a while, but
> >> eventually freezes. I know that freezing is a sign of deadlock.
> >> However,
> >> I put in print statements to localize the problem and discovered
> >> something
> >> weird. The freeze always occurs at a point in the code with the
> >> following
> >> statements:
> >>
> >> print "about to try"
> >> try:
> >> print "in try"
> >> <do something>
> >>
> >> I get "about to try", but not "in try". Is this observation consistent
Try putting a flush in after the 2nd print statement in case the output
is left in some I/O buffer when the thing terminates. e.g.
import sys
....
try:
print 'in try"
sys.stdout.flush()
<do something>
--
-- Lou Pecora
More information about the Python-list
mailing list