Comments (4)
ok, this actually ends up being a problem with the mrb object not being re-entrant... in mruby itself when entered externally with load_string. I'm not entirely certain this would work with mruby without golang either.
Conversely, this code executes just fine, allocating a single interpreter per goroutine:
// main.go
package main
import (
"sync"
"github.com/mitchellh/go-mruby"
)
func main() {
var wg sync.WaitGroup
for i := 1; i < 50000; i++ {
wg.Add(1)
go func() {
mrb := mruby.NewMrb()
defer mrb.Close()
mrb.LoadString("puts 'hola mundo'")
wg.Done()
}()
}
wg.Wait()
}
since this is a resolution you can take today, I strongly suggest you take it. You can wrap mutual accesses with mutex locks of your own devising, allowing you to load code sequentially from different goroutines. Alternatively, you can feed that code through a channel and load it serially.
we can do this as well; I just need to think of the situations that can go wrong by embedding a mutex in the struct around these operations, and whether or not it's better to just say "deal with it yourself". If other maintainers have a solution they like, please chime in.
from go-mruby.
from go-mruby.
from go-mruby.
did this ever get fixed?
from go-mruby.
Related Issues (20)
- mruby.Run does not work with a Proc returned from LoadString HOT 6
- mruby.Hash / mruby.Array may not behave as ruby users expect
- mrb_load_file panics due to an expired syscall HOT 7
- Passing large string back to mruby HOT 6
- Array is missing methods for mutating it HOT 2
- It's not clear from the docs how different types should be initialised from Go
- fatal error: exitsyscall: syscall frame is no longer valid HOT 18
- There is no license or copying file HOT 2
- Readme missing dependencies HOT 3
- Can't tell from the docs but is there an Encode which is the pair of Decode HOT 7
- How can I get `Hash` value via a `Symbol` key? HOT 1
- Tests doesn't pass on go1.10 HOT 2
- Execute compiled code
- Help me understand LoadString, unexpected behavior HOT 3
- mruby 1.4.1 dispatch breaks go-mruby
- Build fails with: could not determine kind of name for C.mrb_ary_len HOT 7
- golint moved things again
- Ruby calling Go code
- State of this Project? mruby 3.0.0? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-mruby.