STINNER Victor <vstin...@redhat.com> added the comment:

There is a special case. If a thread calls os.fork() and Thread.run() raises an 
exception, the thread name is still logged even if there is only 1 thread after 
fork. Try attached fork_thread.py.

Output on Python 3.7:
---
main thread: spawn fork thread
thread: before fork [<_MainThread(MainThread, started 140623217481536)>, 
<ForkThread(Thread-1, started 140622996952832)>]
thread: after fork [<ForkThread(Thread-1, started 140622996952832)>]
thread: after fork: raise
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib64/python3.7/threading.py", line 917, in _bootstrap_inner
    self.run()
  File "fork_thread.py", line 17, in run
    raise Exception("what happens here?")
Exception: what happens here?

main thread: done
---

Moreover, threading.Thread silently ignores SystemExit in run() even if it's 
the only remaining thread (main thread is gone after fork).

I don't think that we *have to* change the current behavior. It's just that we 
have to take it in account if we modify how exceptions are handled.

----------
Added file: https://bugs.python.org/file48351/fork_thread.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue1230540>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to