[New-bugs-announce] [issue29658] Process hangs (sometimes)

djstrong report at bugs.python.org
Sun Feb 26 08:48:30 EST 2017


New submission from djstrong:

I have this code, which sometimes hangs (1 of 5 runs):

# -*- coding: utf-8 -*-

import sys
import threading
import multiprocessing

mpl = multiprocessing.log_to_stderr()
mpl.setLevel(1)


class A(threading.Thread):
    def __init__(self):
        super(A, self).__init__()

    def run(self):
        print(self.name, 'RUN')

        for line in sys.stdin: #increases probability of hanging
            pass

        print(self.name, 'STOP')


class B(multiprocessing.Process):
    def __init__(self):
        super(B, self).__init__()

    def run(self):
        print(self.name, 'RUN')


a = A()
a.start()

b = B()
b.start()
print('B started', b, b.is_alive(), b.pid)
print('A', a)

a.join()
b.join()

print('FINISHED')

I am running it on Ubuntu with command: echo "" | python3 time_test4.py

Output is:
Thread-1 RUN
B started <B(B-1, started)> True 31439
A <A(Thread-1, started 139779252864768)>
Thread-1 STOP

----------
messages: 288594
nosy: djstrong
priority: normal
severity: normal
status: open
title: Process hangs (sometimes)
type: behavior
versions: Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29658>
_______________________________________


More information about the New-bugs-announce mailing list