threading issues with D -> C -> Python

Michael via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Dec 2 18:21:45 PST 2014


Thanks for this. Its definitely a step in the right direction. 
Would you mind explaining a bit more about the problem here, if 
you can? I don't fully understand why the garbage collector needs 
to know about the threads, and if so for how long does it need to 
know? If I put in 
"thread_attachThis();scope(exit)thread_detachThis();" it doesn't 
appear to fix my problems, so I'm definitely curious as to what 
is going on under the hood.

Cheers,
Michael.

On Wednesday, 3 December 2014 at 01:17:43 UTC, ketmar via 
Digitalmars-d-learn wrote:
> On Wed, 03 Dec 2014 01:07:42 +0000
> Michael via Digitalmars-d-learn 
> <digitalmars-d-learn at puremagic.com>
> wrote:
>
>> I'm fairly sure I have tackled both of these issues, but it 
>> still seems like Python threads and D threads don't mix well. 
>> When running the same functions from D, I am able to get no 
>> errors, but when run from Python/C it causes segfaults 
>> reliably.
> you are right, D threads and other language/library threads 
> aren't mix
> well. at least you have to use `thread_attachThis()` and
> `thread_detachThis()` from core.threads module to make sure 
> that GC is
> aware of "alien" threads. and i assume that calling this 
> functions
> from python will not be very easy.
>
> but it's better to not mix 'em at all if it is possible.



More information about the Digitalmars-d-learn mailing list