[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-06-09 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

 Oh, sigwait() doesn't accept a timeout! I would be nice to have
 also sigwaitinfo().. and maybe also its friend, sigwaitinfo() 

Oops, I mean sigtimedwait() and sigwaitinfo().

--

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-06-09 Thread Charles-François Natali

Charles-François Natali neolo...@free.fr added the comment:

I just noticed something funny: signal_sigwait doesn't release the
GIL, which means that it's pretty much useless :-)
Patch attached.
Also, test_sigwait doesn't block the signal before calling sigwait: it
happens to work because there's only one thread, but it's undefined
behaviour.

--
Added file: http://bugs.python.org/file22300/sigwait_gil.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8407
___--- cpython-302424b84b07/Modules/signalmodule.c 2011-06-01 02:39:38.0 
+
+++ cpython/Modules/signalmodule.c  2011-06-09 11:39:28.0 +
@@ -662,7 +662,9 @@
 if (iterable_to_sigset(signals, set))
 return NULL;
 
+Py_BEGIN_ALLOW_THREADS
 err = sigwait(set, signum);
+Py_END_ALLOW_THREADS
 if (err) {
 errno = err;
 return PyErr_SetFromErrno(PyExc_OSError);
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-06-09 Thread Giampaolo Rodola'

Giampaolo Rodola' g.rod...@gmail.com added the comment:

This whole thread is becoming quite confusing.
It would be better to open a separate issue for any bug or feature request 
which is not related to exposing signalfd(2) and pthread_sigmask.

--

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-06-08 Thread Giampaolo Rodola'

Changes by Giampaolo Rodola' g.rod...@gmail.com:


--
nosy: +giampaolo.rodola

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-05-31 Thread Charles-François Natali

Charles-François Natali neolo...@free.fr added the comment:

 The wakeup fd now contains the number of each signal, and so the behaviour has
 to change. I applied your patch and I added a test.

Interesting. I suspected this would have an impact on the test_signal
failure on the FreeBSD 6.4 buidbot:


==
FAIL: test_signum (test.test_signal.WakeupSignalTests)
--
Traceback (most recent call last):
  File 
/usr/home/db3l/buildarea/3.x.bolen-freebsd/build/Lib/test/test_signal.py,
line 272, in test_signum
self.check_signum(signal.SIGUSR1, signal.SIGALRM)
  File 
/usr/home/db3l/buildarea/3.x.bolen-freebsd/build/Lib/test/test_signal.py,
line 238, in check_signum
self.assertEqual(raised, signals)
AssertionError: Tuples differ: (14, 30) != (30, 14)

First differing element 0:
14
30

- (14, 30)
+ (30, 14)


This means that the signals are not delivered in order.
Normally, pending signals are checked upon return to user-space, so
trip_signal should be called when the kill syscall returns, so signal
numbers should be written in order to the wakeup FD (and here it looks
like the lowest-numbered signal is delivered first).
You could try adding a short sleep before the second kill (or just
pass unordered=True to check_signum, but in that case we don't check
the correct ordering).

--

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-05-31 Thread Roundup Robot

Roundup Robot devnull@devnull added the comment:

New changeset 29e08a98281d by Victor Stinner in branch 'default':
Issue #8407: test_signal doesn't check signal delivery order
http://hg.python.org/cpython/rev/29e08a98281d

--

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-05-31 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

Cool, x86 FreeBSD 6.4 3.x is green for the first time since a long time, 
thanks to my commit 29e08a98281d (test_signal doesn't check signal delivery 
order).

--

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-05-27 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

Oh, sigwait() doesn't accept a timeout! I would be nice to have also 
sigwaitinfo().. and maybe also its friend, sigwaitinfo() (if we implement the 
former, it's trivial to implement the latter). Python 3.3 adds optional timeout 
to subprocess.wait(), subprocess.communicate(), threading.Lock.acquire(), etc. 
And I love timeout! It was really useful to implement the thread of 
faulthandler.dump_tracebacks_later().

--

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-05-24 Thread Charles-François Natali

Charles-François Natali neolo...@free.fr added the comment:

 New changeset f8c49a930015 by Victor Stinner in branch 'default':
 Issue #8407: The signal handler writes the signal number as a single byte
 http://hg.python.org/cpython/rev/f8c49a930015

There's a race.
If a signal is received while is_tripped is set, the signal number won't be 
written to the wakeup FD.
Patch attached.

--
Added file: http://bugs.python.org/file22093/sig_wakeup_race.diff

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-05-24 Thread Roundup Robot

Roundup Robot devnull@devnull added the comment:

New changeset 234021dcad93 by Victor Stinner in branch 'default':
Issue #8407: Fix the signal handler of the signal module: if it is called
http://hg.python.org/cpython/rev/234021dcad93

--

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-05-24 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

 There's a race. If a signal is received while is_tripped is set, 
 the signal number won't be written to the wakeup FD.

Oh, nice catch. The bug is not new, Python behaves like that since Python 
3.1. But in Python  3.3, it doesn't mater because I don't think that wakeup 
was used to watch more than one signal. One trigger something happened was 
enough.

The wakeup fd now contains the number of each signal, and so the behaviour has 
to change. I applied your patch and I added a test.

--

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-05-09 Thread Stefan Krah

Stefan Krah stefan-use...@bytereef.org added the comment:

There are warnings on the FreeBSD and OSX buildbots, where pthread_t
is not a long.

http://www.python.org/dev/buildbot/all/builders/AMD64%20FreeBSD%208.2%203.x/builds/237/steps/compile/logs/warnings%20%283%29

http://www.python.org/dev/buildbot/all/builders/AMD64%20Leopard%203.x/builds/1336/steps/compile/logs/warnings%20%2828%29

--
nosy: +skrah

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-05-09 Thread Roundup Robot

Roundup Robot devnull@devnull added the comment:

New changeset 2e0d3092249b by Victor Stinner in branch 'default':
Issue #8407: Use an explicit cast for FreeBSD
http://hg.python.org/cpython/rev/2e0d3092249b

--

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-05-08 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

 New changeset f8c49a930015 by Victor Stinner in branch 'default':
 Issue #8407: The signal handler writes the signal number as a single byte

Wakeup test using two pending signals fails on FreeBSD 6.4 buildbot:

==
FAIL: test_signum (test.test_signal.WakeupSignalTests)
--
Traceback (most recent call last):
  File 
/usr/home/db3l/buildarea/3.x.bolen-freebsd/build/Lib/test/test_signal.py, 
line 266, in test_signum
self.check_signum(signal.SIGUSR1, signal.SIGALRM)
  File 
/usr/home/db3l/buildarea/3.x.bolen-freebsd/build/Lib/test/test_signal.py, 
line 232, in check_signum
self.assertSequenceEqual(raised, signals)
AssertionError: Sequences differ: (14,) != (30, 14)

Wakeup file only contains SIGALRM, not (SIGUSR1, SIGALRM), whereas SIGUSR1 is 
raised before SIGALRM.

Code of the test:

def check_signum(self, *signals):   
data = os.read(self.read, len(signals)+1)   
raised = struct.unpack('%uB' % len(data), data) 
self.assertSequenceEqual(raised, signals)

def test_signum(self):  
old_handler = signal.signal(signal.SIGUSR1, lambda x,y:None)
self.addCleanup(signal.signal, signal.SIGUSR1, old_handler) 
os.kill(os.getpid(), signal.SIGUSR1)
os.kill(os.getpid(), signal.SIGALRM)
self.check_signum(signal.SIGUSR1, signal.SIGALRM)

--

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-05-08 Thread Jesús Cea Avión

Changes by Jesús Cea Avión j...@jcea.es:


--
nosy: +jcea

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-05-07 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

 I mistakenly removed your pending_signals-2 patch
 I'm really sorry about this, could you re-post it?

No problem, anyway I worked on a new version in the train.

 So, if anything, you shouldn't check for a pending signal [in sigwait]

Right, fixed in the new patch.

--

pending_signals-3.patch:
 - don't check for pending signals in sigwait()
 - pthread_kill() doc: it is not a good idea to say that pthread_kill() with 
signum=0 can be used to check if a thread identifier is valid = such test does 
crash (SIGSEGV) on my Linux box. I changed the doc to say that it can be used 
to check if a thread is still running (which is different).
 - add a dedicated test for sigpending()
 - doc: explain how to get a thread identifier for pthread_kill()
 - don't compile pthread_kill() without threads: you cannot get a valid thread 
identifier without the _thread module

I think that the patch is ready to be commited. Anyone for a last review? 
(antoine, neologix?)

--
Added file: http://bugs.python.org/file21921/pending_signals-3.patch

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-05-07 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

Note: we might expose pth_raise() which is similar to pthread_kill(), but... 
pth support was deprecated by the PEP 11 and pth support will be removed from 
Python 3.3 source code.

--

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-05-07 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

About signalfd(): this patch doesn't provide any information or tool to decode 
data written to the file descriptor. We should expose the signalfd_siginfo 
structure or you cannot handle more than one signal (how do you know which 
signal numbers were raised?). Example with ctypes:

class signalfd_siginfo(Structure):
_fields_ = (
('ssi_signo', c_uint32),# Signal number
('ssi_errno', c_int32), # Error number (unused)
('ssi_code', c_int32),  # Signal code
('ssi_pid', c_uint32),  # PID of sender
('ssi_uid', c_uint32),  # Real UID of sender
('ssi_fd', c_int32),# File descriptor (SIGIO)
('ssi_tid', c_uint32),  # Kernel timer ID (POSIX timers)
('ssi_band', c_uint32), # Band event (SIGIO)
('ssi_overrun', c_uint32),  # POSIX timer overrun count
('ssi_trapno', c_uint32),   # Trap number that caused signal
('ssi_status', c_int32),# Exit status or signal (SIGCHLD)
('ssi_int', c_int32),   # Integer sent by sigqueue(2)
('ssi_ptr', c_uint64),  # Pointer sent by sigqueue(2)
('ssi_utime', c_uint64),# User CPU time consumed (SIGCHLD)
('ssi_stime', c_uint64),# System CPU time consumed (SIGCHLD)
('ssi_addr', c_uint64), # Address that generated signal
# (for hardware-generated signals)
('_padding', c_char * 46),  # Pad size to 128 bytes (allow for
# additional fields in the future)
)

--

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-05-07 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

wakeup_signum.patch: simple patch to write the signal number (as a single byte) 
instead of just b'\x00' into the wake up file descriptor. It gives the ability 
to watch more than one signal and be able to know which one was raised. 
Included tests demonstrate the feature. The doc explains how to decode data 
written to the file descriptor.

--
Added file: http://bugs.python.org/file21922/wakeup_signum.patch

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-05-07 Thread STINNER Victor

Changes by STINNER Victor victor.stin...@haypocalc.com:


Removed file: http://bugs.python.org/file21883/pending_signals.patch

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-05-07 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

pending_signals-3.patch: doc nit, the link to Thread.ident doesn't work. The 
doc should be replaced by something like:
  
   *thread_id* can be read from the :attr:`~threading.Thread.ident` attribute   
   of a :class:`threading.Thread` object.  For example, 
   ``threading.current_thread().ident`` gives the identifier of the current 
   thread.

... but ident or Thread are not link, I don't know why.

--

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-05-07 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

The threading has a function to get directly the identifier of the current 
thread: threading._get_ident() instead of threading.current_thread().ident. I 
think that threading._get_ident() is more reliable to 
threading.current_thread().ident because Thread.ident can be None in some 
cases. I created the issue #12028 to decide what to do with this function.

--

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-05-07 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

 pending_signals-3.patch:
  - don't check for pending signals in sigwait()
  - pthread_kill() doc: it is not a good idea to say that pthread_kill() with 
 signum=0 can be used to check if a thread identifier is valid = such test 
 does crash (SIGSEGV) on my Linux box. I changed the doc to say that it can be 
 used to check if a thread is still running (which is different).
  - add a dedicated test for sigpending()
  - doc: explain how to get a thread identifier for pthread_kill()
  - don't compile pthread_kill() without threads: you cannot get a valid 
 thread identifier without the _thread module
 
 I think that the patch is ready to be commited. Anyone for a last
 review? (antoine, neologix?)

It looks good to me.
It's very nice to have all these extra functions :)

--

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-05-07 Thread Roundup Robot

Roundup Robot devnull@devnull added the comment:

New changeset 1d8a57deddc4 by Victor Stinner in branch 'default':
Issue #8407: Add pthread_kill(), sigpending() and sigwait() functions to the
http://hg.python.org/cpython/rev/1d8a57deddc4

--

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-05-07 Thread Roundup Robot

Roundup Robot devnull@devnull added the comment:

New changeset f8c49a930015 by Victor Stinner in branch 'default':
Issue #8407: The signal handler writes the signal number as a single byte
http://hg.python.org/cpython/rev/f8c49a930015

--

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-05-07 Thread Roundup Robot

Roundup Robot devnull@devnull added the comment:

New changeset e3cb2c99a5a9 by Victor Stinner in branch 'default':
Issue #8407: Remove debug code from test_signal
http://hg.python.org/cpython/rev/e3cb2c99a5a9

--

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-05-07 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

Update the signalfd patch (version 4) against the default branch. Specify the 
minimum Linux version in signalfd() doc. The patch still lacks a structure to 
parse the bytes written into the file (see msg135438 for a ctypes example): a 
struct sequence should be fine.

--
Added file: http://bugs.python.org/file21930/signalfd-4.patch

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-05-06 Thread Charles-François Natali

Changes by Charles-François Natali neolo...@free.fr:


Removed file: http://bugs.python.org/file21901/pending_signals-2.patch

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-05-06 Thread Charles-François Natali

Charles-François Natali neolo...@free.fr added the comment:

Oops.
Victor, my mouse got stuck and I mistakenly removed your pending_signals-2 
patch. I'm really sorry about this, could you re-post it?

To try to make up for this, a small comment:
In signal_sigwait, at the end of the function,  you do this:

/* call the signal handler (if any) */
if (PyErr_CheckSignals())
return NULL;

I'm not sure I get this: sigwait is used to handle signals synchronously, and 
in the POSIX semantic, it's incompatible with signal handlers:


sigwait suspends the calling thread until one of the signals in set is 
delivered to the calling thread. It then stores the number of the signal 
received in the location pointed to by sig and returns. The signals in set must 
be blocked and not ignored on entrance to sigwait. If the delivered signal has 
a signal handler function attached, that function is *not* called.


and

The effect of sigwait() on the signal actions for the signals in set is 
unspecified.


So, if anything, you shouldn't check for a pending signal.

--
nosy: +neologix

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-05-05 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

Quick review at http://bugs.python.org/review/8407/show

--

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-05-05 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

 http://bugs.python.org/review/8407/show

Updated patch (version 2).

Note: sigpending() doesn't return an error code but -1 on error.

--
Added file: http://bugs.python.org/file21901/pending_signals-2.patch

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-05-04 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

 c) Skip the test if the _tkinter thread is present (...)

I opened issue #11998 for the problem with test_signal and the _tkinter module. 
To get back green buildbots, I commited a workaround:

New changeset 88dca05ed468 by Victor Stinner in branch 'default':
Issue #11998, issue #8407: workaround _tkinter issue in test_signal
http://hg.python.org/cpython/rev/88dca05ed468

 a) Use pthread_kill() to send the signal directly
 to the right thread (...)

I'm still working on this solution to test blocked signals even if _tkinter is 
loaded.

--

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-05-04 Thread Roundup Robot

Roundup Robot devnull@devnull added the comment:

New changeset a5890ff5e3d5 by Victor Stinner in branch 'default':
Issue #8407: signal.pthread_sigmask() returns a set instead of a list
http://hg.python.org/cpython/rev/a5890ff5e3d5

--

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-05-04 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

pending_signals.patch: add pthread_kill(), sigpending() and sigwait() functions 
with doc and tests.

I added many See also in the doc, e.g. os.kill() gives a link to 
signal.pthread_kill().

Note: the patch renames also BasicSignalTests to PosixTests, it's not related 
to the other changes.

--
Added file: http://bugs.python.org/file21883/pending_signals.patch

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-05-03 Thread Roundup Robot

Roundup Robot devnull@devnull added the comment:

New changeset d003ce770ba1 by Victor Stinner in branch 'default':
Issue #8407: Fix pthread_sigmask() tests on Mac OS X
http://hg.python.org/cpython/rev/d003ce770ba1

--

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-05-03 Thread Roundup Robot

Roundup Robot devnull@devnull added the comment:

New changeset c9207c6ce24a by Victor Stinner in branch 'default':
Issue #8407: pthread_sigmask() checks immediatly if signal handlers have been
http://hg.python.org/cpython/rev/c9207c6ce24a

--

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-05-03 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

Since the commit c9207c6ce24a, test_signal fails on OpenIndiana:

http://www.python.org/dev/buildbot/all/builders/x86%20OpenIndiana%203.x/builds/1179
==
ERROR: test_block_unlock (test.test_signal.PthreadSigmaskTests)
--
Traceback (most recent call last):
  File 
/export/home/buildbot/64bits/3.x.cea-indiana-amd64/build/Lib/test/test_signal.py,
 line 539, in test_block_unlock
self.assertEqual(set(old_mask) ^ set(blocked), {signum})
  File 
/export/home/buildbot/64bits/3.x.cea-indiana-amd64/build/Lib/test/test_signal.py,
 line 501, in handler
1/0
ZeroDivisionError: division by zero

--

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-05-03 Thread Roundup Robot

Roundup Robot devnull@devnull added the comment:

New changeset 96a532eaa2d1 by Victor Stinner in branch 'default':
Issue #8407: disable faulthandler timeout thread on all platforms
http://hg.python.org/cpython/rev/96a532eaa2d1

--

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-05-03 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

 Since the commit c9207c6ce24a, test_signal fails on OpenIndiana:
 
 http://www.python.org/dev/buildbot/all/builders/x86%20OpenIndiana%203.x/builds/1179
 ==
 ERROR: test_block_unlock (test.test_signal.PthreadSigmaskTests)
 --
 Traceback (most recent call last):
   File 
 /export/home/buildbot/64bits/3.x.cea-indiana-amd64/build/Lib/test/test_signal.py,
  line 539, in test_block_unlock
 self.assertEqual(set(old_mask) ^ set(blocked), {signum})
   File 
 /export/home/buildbot/64bits/3.x.cea-indiana-amd64/build/Lib/test/test_signal.py,
  line 501, in handler
 1/0
 ZeroDivisionError: division by zero

This is because a thread different than the main thread receives the
signal and calls the signal handler. Antoine found that python -m
test_pydoc test_signal is enough to reproduce the problem (on any OS,
or at least on Linux). test_pydoc loads a lot (all?) of Python modules
including _tkinter, and _tkinter (libtcl) creates a C thread which waits
events using select().

I see 3 solutions:

a) Use pthread_kill() to send the signal directly to the right thread
(the main thread)

b) Destroy _tkinter: Tcl_Finalize() exits the thread, but this function
is never called. _tkinter.c contains the following code:
#if 0
/* This was not a good idea; through Destroy bindings,
   Tcl_Finalize() may invoke Python code but at that point the
   interpreter and thread state have already been destroyed! */
Py_AtExit(Tcl_Finalize);
#endif

c) Skip the test if the _tkinter thread is present. Check if the
_tkinter module is loaded *should* be enough to check if the Tcl thread
is running. Unload the _tkinter module is not possible: modules written
in C cannot be unloaded. But it is possible to remove all references
from the Python object space, so check '_tkinter' in sys.modules is
maybe not reliable.

I don't know if some platforms have pthread_sigmask() but not
pthread_kill().

I have a patch to expose pthread_kill(), sigpending() and sigwait(). I
will publish it tomorrow for a review.

--

test_signal doesn't fail on all platforms. Possible reasons:

 - the platform doesn't have pthread_sigmask(), and so the test is
skipped
 - the libtcl version is different, a newer version masks maybe signals?
 - (unlikely!) os.kill() always sends the signal to the main thread

--

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-05-02 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

test_signal.PthreadSigmaskTests fails on Mac OS X.

http://www.python.org/dev/buildbot/all/builders/PPC Leopard 
3.x/builds/1785/steps/test/logs/stdio
http://www.python.org/dev/buildbot/all/builders/PPC Tiger 
3.x/builds/1748/steps/test/logs/stdio
---
[186/354] test_signal
make: *** [buildbottest] User defined signal 1


http://www.python.org/dev/buildbot/all/builders/x86 Tiger 
3.x/builds/2429/steps/test/logs/stdio
---
Re-running test 'test_signal' in verbose mode
...
test_arguments (test.test_signal.PthreadSigmaskTests) ... ok
test_block_unlock (test.test_signal.PthreadSigmaskTests) ... make: *** 
[buildbottest] User defined signal 1
program finished with exit code 2
---

--

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-05-02 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

Update signalfd patch.

--
Added file: http://bugs.python.org/file21856/signalfd-2.patch

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-05-02 Thread STINNER Victor

Changes by STINNER Victor victor.stin...@haypocalc.com:


Removed file: http://bugs.python.org/file21841/signalfd.patch

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-05-02 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

 Update signalfd patch.
 
 --
 Added file: http://bugs.python.org/file21856/signalfd-2.patch

- In the tests, you don't need sys.exc_info(), just
except XXXError as e.
- In the doc, you wrote file description instead of file descriptor
- In test_out_of_range_signal, you should use assertRaises

--

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-05-02 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

Fixed: updated patch (version 3).

--
Added file: http://bugs.python.org/file21857/signalfd-3.patch

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-05-02 Thread STINNER Victor

Changes by STINNER Victor victor.stin...@haypocalc.com:


Removed file: http://bugs.python.org/file21856/signalfd-2.patch

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-05-02 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

 test_signal.PthreadSigmaskTests fails on Mac OS X.

The problem is that sometimes SIG_UNBLOCK does not immediatly call the pending 
signal, but it calls it later. The problem is that I don't know exactly when. 
I tried to wait the pending signal using signal.pause(), but I got a bus error!?

Example of the problem:

pthread_sigmask(SIG_BLOCK, [SIGUSR1])
os.kill(os.getpid(), SIGUSR1)
pthread_sigmask(SIG_UNBLOCK, [SIGUSR1])

--

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-04-30 Thread Roundup Robot

Roundup Robot devnull@devnull added the comment:

New changeset 28b9702a83d1 by Victor Stinner in branch 'default':
Issue #8407, issue #11859: Add signal.pthread_sigmask() function to fetch
http://hg.python.org/cpython/rev/28b9702a83d1

--
nosy: +python-dev

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-04-30 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

signalfd.patch: Add signal.signalfd(), signal.SFD_CLOEXEC and 
signal.SFD_NONLOCK.

The patch is based on http://codereview.appspot.com/1132041 and the last 
version (bzr) of python-signalfd.

The patch uses also PyModule_AddIntMacro() for the 3 constants added in my last 
(pthread_sigmask), and changes pthread_sigmask() to raise an OSError instead of 
a RuntimeError.

Note: python-signalfd has a bug: it doesn't pass the fd argument to signalfd(), 
it always pass -1.

--
Added file: http://bugs.python.org/file21841/signalfd.patch

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



[issue8407] expose signalfd(2) and pthread_sigmask in the signal module

2011-04-22 Thread STINNER Victor

Changes by STINNER Victor victor.stin...@haypocalc.com:


--
title: expose signalfd(2) and sigprocmask(2) in the signal module - expose 
signalfd(2) and pthread_sigmask in the signal module

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