-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Thread safety issue #183
Comments
any update ? |
Any plan to fix it ? |
I'm not nine (IP5 author). But I saw that you'd not gotten a response and decided to see if I can help. Some thoughts:
|
@Zer0-Tolerance sorry for the radio silence. I have let myself get sucked into $day-job to an unhealthy degree and only now realized that that was not a good decision. Your problem is that Perl 5 is just not thread-safe. Indeed that was one of the reasons for starting the whole Perl 6 and now Raku effort. We cannot magically fix that. However, there are some things that indeed are possible. Perl 5 does support running multiple independent interpreters in the same process and Inline::Perl5 makes use of that in its somewhat experimental and apparently totally undocumented threading-support. This works as desired:
What happens here is that in "thread-safe" mode Inline::Perl5 will create on Perl interpreter on each thread that you try to run Perl code on. These interpreters operate independently of each other and must not share any data. So all Perl objects must only be accessed within the same thread that they were created on. This sounds quite restrictive but it's still good enough for many situations like for example using Perl modules in worker threads (think typical web application) and indeed that's what I wrote this support for: to make Perl available to Cro applications. If you do want to share data between multiple threads, this data must be converted to appropriate Raku types first. One more caveat is that this support currently only exists for modules imported with |
Hi,
I'm getting a lot of crashes when I use P5 code with promise, it seems that when you reach a certain amount of threads a kind of race condition is triggered. The following code reproduces the problem easily:
I'm using the following Perl5 :
Any idea how to fix this ?
The text was updated successfully, but these errors were encountered: