v8py icon indicating copy to clipboard operation
v8py copied to clipboard

Threading support?

Open desertkun opened this issue 8 years ago • 5 comments

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.

desertkun avatar Jul 01 '17 12:07 desertkun

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

tbodt avatar Jul 01 '17 14:07 tbodt

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

tbodt avatar Jul 01 '17 14:07 tbodt

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.

desertkun avatar Jul 01 '17 15:07 desertkun

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?

kokhoor avatar Apr 15 '19 16:04 kokhoor

@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.

desertkun avatar Apr 15 '19 19:04 desertkun