[issue23886] faulthandler_user should use _PyThreadState_Current

2016-03-25 Thread Albert Zeyer

Albert Zeyer added the comment:

Yes exactly. Sorry if I was unclear before. :)

I mentioned SIGUSR1/2 because for a segfault, the signal handler will usually 
be executed in the same thread (although I'm not sure if that is guaranteed), 
so that was usually not a problem. But I used SIGUSR1 when my Python 
application is hanging and esp in that case I would like to know the current 
Python active thread.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23886] faulthandler_user should use _PyThreadState_Current

2016-03-25 Thread STINNER Victor

STINNER Victor added the comment:

> I want that it marks the current Python thread correctly, and not the current 
> sighandler thread.

Oook, I finally understood your use case. You want to know which threads 
hold the GIL. You don't care which thread got the signal.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23886] faulthandler_user should use _PyThreadState_Current

2016-03-23 Thread Albert Zeyer

Albert Zeyer added the comment:

PyGILState_GetThisThreadState might not be the same Python thread as 
_PyThreadState_Current, even in the case that both are not NULL. That is 
because SIGUSR1/2 will get delivered to any running thread. In the output by 
faulthandler, I want that it marks the current Python thread correctly, and not 
the current sighandler thread.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23886] faulthandler_user should use _PyThreadState_Current

2016-03-23 Thread STINNER Victor

STINNER Victor added the comment:

faulthandler was enhanced in Python 3.6:

* Issue #26563: faulthandler now works in non-Python threads.
* Issue #26154: Issue #26154: Add a new private _PyThreadState_UncheckedGet() 
function which gets the current thread state, but don't call Py_FatalError() if 
it is NULL.

Can you please try Python 3.6 (default branch of Mercurial) with your use case 
to check if the issue is solved? And also Python 3.5 (3.5 branch of Mercurial)?

I can try to backport some enhancements from Python 3.6 to Python 3.5 if needed.

If it's ok for you, I will then port changes to the GitHub project.

Note: I also add new unit tests.

> SIGUSR1/2 will get delivered to any running thread. The current thread of the 
> signal doesn't give any useful information. Try to get the current Python 
> thread which holds the GIL instead, or use NULL.

I don't understand your usecase, since faulthandler displays *all* Python 
threads by default.

all_threads=True in faulthandler.register(signum, file=sys.stderr, 
all_threads=True, chain=False):
https://docs.python.org/dev/library/faulthandler.html#faulthandler.register

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23886] faulthandler_user should use _PyThreadState_Current

2015-04-08 Thread Albert Zeyer

New submission from Albert Zeyer:

SIGUSR1/2 will get delivered to any running thread. The current thread of the 
signal doesn't give any useful information. Try to get the current Python 
thread which holds the GIL instead, or use NULL.

I have patched this for the external faulthandler module here:
https://github.com/haypo/faulthandler/pull/12
https://github.com/albertz/faulthandler/commit/dc92265

--
components: Library (Lib)
messages: 240252
nosy: Albert.Zeyer
priority: normal
severity: normal
status: open
title: faulthandler_user should use _PyThreadState_Current
type: behavior
versions: Python 3.4, Python 3.5, Python 3.6

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23886
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23886] faulthandler_user should use _PyThreadState_Current

2015-04-08 Thread Ned Deily

Changes by Ned Deily n...@acm.org:


--
nosy: +haypo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23886
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com