tbodt / v8py

Write Python APIs, then call them from JavaScript using the V8 engine.
GNU Lesser General Public License v3.0
440 stars 28 forks source link

Threading support? #8

Open desertkun opened 7 years ago

desertkun commented 7 years ago

Considering to migrate from pyv8, but not sure if this solution allows me to fire multiple Isolates in different threads.

extern Isolate *isolate;

Does not sound like it does.

tbodt commented 7 years ago

Nope. There is currently one true isolate. It would probably be an API breaking change to fix that.

tbodt commented 7 years ago

Or not, maybe extern Isolate *isolate could simply be replaced by a thread local? That feels a little messy though.

desertkun commented 7 years ago

I am fine with default isolate, but perhaps there should be a way to create one from python and then pass it as argument into Context or whatever structures you are using (which breaks no API). And yeah, Locker is to be introduced.

kokhoor commented 5 years ago

My test indicates that multiple thread having own Context can work fine. Is v8py still running on 1 isolate?

If yes, what is potential problem when multithreading with each thread having own Context?

desertkun commented 5 years ago

@kokhoor When I researched this I had too many issues. You'd have to lock/release the GIL in order for threading to actually work. This implies many scenarios like python->js->python calls and introducing GIL to this really explodes the complexity.

tl;dr Don't bother.