Open eukreign opened 10 years ago
From flier...@gmail.com on April 05, 2013 07:50:54
In the recent API changes, V8 engine has a lot of different behaviors :( I would fix it soon
Status: Accepted
Labels: -Type-Defect Type-Enhancement OpSys-All
From serge....@gmail.com on April 05, 2013 08:11:44
I did some research on this: such behaviour is correct since V8 creates contexts as stacks and uses the latest one globally.
I made a workaround for this problem: I explicitly enter required context whenever I need to do something: https://github.com/emmetio/sublime-tern/blob/master/ternjs/context.py#L181 Works fine so far.
From serge....@gmail.com on March 22, 2013 13:34:42
I’m using PyV8 as a base for my Sublime Text plugins. I’ve successfully used PyV8 on my Emmet plugin, but now I’m creating a new plugin and have issues with JS context.
Each plugin creates it’s own JSContext instance that should keep data and exist during plugin lifetime. Context is initiated as follows:
The problem is that PyV8 seems to have just one JS context which is shared across plugins.
For example, if Sublime Text loads plugin A and then B, I can access JS methods of B plugin but not A (error is:
AttributeError: '[object global]' object has no attribute 'XXX'
). If I explicitly reload plugin A (e.g. re-initiate it) I can access methods of A but not B.Here’s how JSContext is used in plugin: https://github.com/sergeche/emmet-sublime/blob/master/emmet/context.py#L170
Original issue: http://code.google.com/p/pyv8/issues/detail?id=167