Python 2.x Threading on FreeBSD

2013-04-21 Thread Gabor Pali
Hi there,

Recently I ran into an issue where multi-threaded programs with
signals cannot be run correctly from a thread in Python 2.x with the
vanilla lang/python27 port, c.f. [1].  As I wrote in the corresponding
ticket, the possible cause for this is that threading has been patched
back in 2009 [2] so I recommended to use GNU pth instead.

However, I managed to catch koobs on IRC yesterday and we continued to
pursue the reason for this problem further.  The aforementioned patch
was a result of handling ports/131080 [3] where the submitter states
that this is a solution to a problem where Ctrl+C cannot be handled
when the main thread is blocked by waiting for another thread.  Note
this patch has been rejected upstream [4]... actually because this is
not a bug but a feature [5][6].

So could you please fix the lang/python2{6,7} ports by removing the
following part from the files/patch-Python_thread__pthread.h:

31 @@ -149,6 +153,7 @@
32   {
33   pthread_t th;
34   int status;
35  +sigset_t set, oset;
36   #if defined(THREAD_STACK_SIZE) || 
defined(PTHREAD_SYSTEM_SCHED_SUPPORTED)
37   pthread_attr_t attrs;
38   #endif
39  @@ -177,6 +182,8 @@
40   #if defined(PTHREAD_SYSTEM_SCHED_SUPPORTED)
41   pthread_attr_setscope(&attrs, PTHREAD_SCOPE_SYSTEM);
42   #endif
43  +sigfillset(&set);
44  +SET_THREAD_SIGMASK(SIG_BLOCK, &set, &oset);
45  
46   status = pthread_create(&th,
47   #if defined(THREAD_STACK_SIZE) || 
defined(PTHREAD_SYSTEM_SCHED_SUPPORTED)
48  @@ -188,6 +195,7 @@
49(void *)arg
50);
51  
52  +SET_THREAD_SIGMASK(SIG_SETMASK, &oset, NULL);
53   #if defined(THREAD_STACK_SIZE) || 
defined(PTHREAD_SYSTEM_SCHED_SUPPORTED)
54   pthread_attr_destroy(&attrs);
55   #endif

Note that I have tested this modification with the program in the
referenced PR and with the program which is failing and both indeed
worked as described in the cited sources.


PS_1: Thanks koobs for helping me with tracking down this issue!
PS_2: Please CC in your replies as I am not on this list.

[1] http://hackage.haskell.org/trac/ghc/ticket/7652
[2] http://svnweb.freebsd.org/ports?view=revision&revision=230031
[3] http://www.freebsd.org/cgi/query-pr.cgi?pr=131080
[4] http://bugs.python.org/issue1975
[5] http://www.regexprn.com/2010/05/killing-multithreaded-python-programs.html
[6] 
https://docs.google.com/viewer?a=v&q=cache:fHDVpJgZl7sJ:www.dabeaz.com/python/GIL.pdf+&hl=en&gl=au&pid=bl&srcid=ADGEESg1OQ8O8lXMSVYrJ813iuu6X-G4539buVO20VRwFvGewPv3PJXWVGen_wQi_SpbL4rIOmfQEwiDyPUJnm8NpIBNObBqmeXRUd7W3hH3W2AcdeRCrT3zK1bnmA4ZeqoJJbalUZeS&sig=AHIEtbTvKZ9pjSW3mbITlDqXRDYovlYrew
 (pages 21, 22, 25)
___
freebsd-python@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-python
To unsubscribe, send any mail to "freebsd-python-unsubscr...@freebsd.org"


Re: ports/178008: www/py-djangotoolbox: unfetchable distfile, fragile

2013-04-21 Thread John Hixson
The following reply was made to PR ports/178008; it has been noted by GNATS.

From: John Hixson 
To: bug-follo...@freebsd.org
Cc:  
Subject: Re: ports/178008: www/py-djangotoolbox: unfetchable distfile, fragile
Date: Sun, 21 Apr 2013 14:16:47 -0700

 On Sat, Apr 20, 2013 at 07:30:18PM +, Edwin Groothuis wrote:
 > Maintainer of www/py-djangotoolbox,
 > 
 > Please note that PR ports/178008 has just been submitted.
 > 
 > If it contains a patch for an upgrade, an enhancement or a bug fix
 > you agree on, reply to this email stating that you approve the patch
 > and a committer will take care of it.
 > 
 > The full text of the PR can be found at:
 > http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/178008
 
 I'll get this fixed some time this week.
 
 - John
 
 > 
 > -- 
 > Edwin Groothuis via the GNATS Auto Assign Tool
 > ed...@freebsd.org
___
freebsd-python@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-python
To unsubscribe, send any mail to "freebsd-python-unsubscr...@freebsd.org"


Re: Python 2.x Threading on FreeBSD

2013-04-21 Thread Kubilay Kocak
On 22/04/2013 3:00 AM, Gabor Pali wrote:
> Hi there,
> 
> Recently I ran into an issue where multi-threaded programs with
> signals cannot be run correctly from a thread in Python 2.x with the
> vanilla lang/python27 port, c.f. [1].  As I wrote in the corresponding
> ticket, the possible cause for this is that threading has been patched
> back in 2009 [2] so I recommended to use GNU pth instead.
> 
> However, I managed to catch koobs on IRC yesterday and we continued to
> pursue the reason for this problem further.  The aforementioned patch
> was a result of handling ports/131080 [3] where the submitter states
> that this is a solution to a problem where Ctrl+C cannot be handled
> when the main thread is blocked by waiting for another thread.  Note
> this patch has been rejected upstream [4]... actually because this is
> not a bug but a feature [5][6].
> 
> So could you please fix the lang/python2{6,7} ports by removing the
> following part from the files/patch-Python_thread__pthread.h:
> 
> 31 @@ -149,6 +153,7 @@
> 32 {
> 33 pthread_t th;
> 34 int status;
> 35+sigset_t set, oset;
> 36 #if defined(THREAD_STACK_SIZE) || 
> defined(PTHREAD_SYSTEM_SCHED_SUPPORTED)
> 37 pthread_attr_t attrs;
> 38 #endif
> 39@@ -177,6 +182,8 @@
> 40 #if defined(PTHREAD_SYSTEM_SCHED_SUPPORTED)
> 41 pthread_attr_setscope(&attrs, PTHREAD_SCOPE_SYSTEM);
> 42 #endif
> 43+sigfillset(&set);
> 44+SET_THREAD_SIGMASK(SIG_BLOCK, &set, &oset);
> 45
> 46 status = pthread_create(&th,
> 47 #if defined(THREAD_STACK_SIZE) || 
> defined(PTHREAD_SYSTEM_SCHED_SUPPORTED)
> 48@@ -188,6 +195,7 @@
> 49  (void *)arg
> 50  );
> 51
> 52+SET_THREAD_SIGMASK(SIG_SETMASK, &oset, NULL);
> 53 #if defined(THREAD_STACK_SIZE) || 
> defined(PTHREAD_SYSTEM_SCHED_SUPPORTED)
> 54 pthread_attr_destroy(&attrs);
> 55 #endif
> 
> Note that I have tested this modification with the program in the
> referenced PR and with the program which is failing and both indeed
> worked as described in the cited sources.
> 
> 
> PS_1: Thanks koobs for helping me with tracking down this issue!
> PS_2: Please CC in your replies as I am not on this list.
> 
> [1] http://hackage.haskell.org/trac/ghc/ticket/7652
> [2] http://svnweb.freebsd.org/ports?view=revision&revision=230031
> [3] http://www.freebsd.org/cgi/query-pr.cgi?pr=131080
> [4] http://bugs.python.org/issue1975
> [5] http://www.regexprn.com/2010/05/killing-multithreaded-python-programs.html
> [6] 
> https://docs.google.com/viewer?a=v&q=cache:fHDVpJgZl7sJ:www.dabeaz.com/python/GIL.pdf+&hl=en&gl=au&pid=bl&srcid=ADGEESg1OQ8O8lXMSVYrJ813iuu6X-G4539buVO20VRwFvGewPv3PJXWVGen_wQi_SpbL4rIOmfQEwiDyPUJnm8NpIBNObBqmeXRUd7W3hH3W2AcdeRCrT3zK1bnmA4ZeqoJJbalUZeS&sig=AHIEtbTvKZ9pjSW3mbITlDqXRDYovlYrew
>  (pages 21, 22, 25)
> ___
> freebsd-python@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-python
> To unsubscribe, send any mail to "freebsd-python-unsubscr...@freebsd.org"
> 

Nice write-up Gabor, and you're welcome.

+1 on this and any other patch-removals that get us closer to upstream
___
freebsd-python@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-python
To unsubscribe, send any mail to "freebsd-python-unsubscr...@freebsd.org"