|Summary:||Problem with signals in threads in lang/python|
|Product:||Ports & Packages||Reporter:||Andriy Pylypenko <bamby>|
|Component:||Individual Port(s)||Assignee:||freebsd-python (Nobody) <python>|
|Severity:||Affects Only Me|
Description Andriy Pylypenko 2009-01-28 13:10:01 UTC
Almost a year ago I've created an issue in Python's bugtracker but the issue seems to be stuck since then so I'm sending the patch here in hope it could be included in ports collection. In short there is a problem in the Python that can be seen under FreeBSD and Sun Solaris but not under MacOSX or Linux. The problem is that when a Python program started a thread in a background, then it can be impossible to interrupt the program with Ctrl-C. The reason why this problem is FreeBSD specific is that the FreeBSD has different order of processing of signals. The signal handler under FreeBSD fires up in the context of the last started thread, while under Linux signals are processed in the main thread. It should be noted that both behaviors are standards conformant. This bug at Python bugtracker: http://bugs.python.org/issue1975 Fix: To ensure that signal handler runs in the correct thread context the developer should use pthread_sigmask(). Initially the Python contained this code but starting from Python 2.4 it was thrown away. The attached patch restores the code that ensures correct execution context of the signal handler code. Patch attached with submission follows: How-To-Repeat: Here is an example script. Start it and try to interrupt by hitting ^C. import time import select from threading import Thread some_time = 6000000 # seconds class MyThread(Thread): def run(self): while (True): time.sleep(some_time) t = MyThread() t.setDaemon(True) t.start() while(True): select.select(, , , some_time)
Comment 1 Edwin Groothuis 2009-01-29 10:40:53 UTC
Responsible Changed From-To: freebsd-ports-bugs->python Over to maintainer (via the GNATS Auto Assign Tool)
Comment 2 Mark Linimon 2009-02-02 11:38:37 UTC
Responsible Changed From-To: python->freebsd-python Canonicalize assignment.
Comment 3 dfilter service 2009-02-27 01:25:50 UTC
sobomax 2009-02-27 01:25:32 UTC FreeBSD ports repository Modified files: lang/python24 Makefile lang/python25 Makefile lang/python26 Makefile Added files: lang/python24/files patch-Python_thread__pthread.h lang/python25/files patch-Python_thread__pthread.h lang/python26/files patch-Python_thread__pthread.h Log: Make sure the singal is delivered to the main thread, where python runs its signal handlers, not to a random thread that happens to be executing at the time when signal arrives. This functionality has been lost since Python 2.3, possible cause is that the linux implementation of POSIX threads always delivered signal to the main thread. This bug results in rather annoying inability to terminate threading script with ^C for example and there could be other issues as well. Bump PORTREVISION. PR: ports/131080 Submitted by: Andriy Pylypenko <firstname.lastname@example.org> Approved by: MAINTAINER's timeout Revision Changes Path 1.166 +1 -1 ports/lang/python24/Makefile 1.1 +30 -0 ports/lang/python24/files/patch-Python_thread__pthread.h (new) 1.154 +1 -0 ports/lang/python25/Makefile 1.1 +30 -0 ports/lang/python25/files/patch-Python_thread__pthread.h (new) 1.156 +1 -1 ports/lang/python26/Makefile 1.1 +30 -0 ports/lang/python26/files/patch-Python_thread__pthread.h (new) _______________________________________________ email@example.com mailing list http://lists.freebsd.org/mailman/listinfo/cvs-all To unsubscribe, send any mail to "firstname.lastname@example.org"
Comment 4 Mark Linimon 2009-03-11 05:56:42 UTC
State Changed From-To: open->closed Committed by sobomax 2009-02-27.