Marc Weber wrote:
> > > > Please explain what this would do what vim.command() isn't doing.
> > > > I mean the one explained below ":he python-vim".
> > >
> > > You can start multiple threads in python. The help didn't say tat
> > > vim.command() is thread safe. However it would be nice to replace this
> > > executeVimCommand hackery with a more native, non blocking thread safe
> > > command. Then you could start writing nice interfaces for debuggers
> > > more easily.
> >
> > I do think that vim.command() is thread safe. Not 100% sure, I didn't
> > look at the detailed documentation for Python native interface. The
> > code contains:
> >
> > Py_BEGIN_ALLOW_THREADS
> > Python_Lock_Vim();
> >
> > do_cmdline_cmd((char_u *)cmd);
> > update_screen(VALID);
> >
> > Python_Release_Vim();
> > Py_END_ALLOW_THREADS
> >
> > Looks like a lock is used to guarantee only one command is done at a
> > time. And that's required, since the Vim core is defenitely not
> > thread-safe.
>
> Hi Bram,
>
> Could you try running the testcase at the end of the file?
> it starts 200 threads each running a loop
> 200 times running vim.cmd.
> It segfaults here.
Sorry, I don't have time for this. Perhaps you can ask Sumner Hayes, he
last did some work on the Python interface.
> Have you actually had a look at the code. The implementation is empty
> (stripped :)
> static void Python_Lock_Vim(void) { }
> static void Python_Release_Vim(void) { }
> :-)
> no actions (current SVN HEAD)
> I've also searched for Py_BEGIN_ALLOW_THREADS. All occurences are within
> if_pyhton.c
>
> Even if the a lock had been aquired there it wouldn't have been
> enough unless vim does so itself:
> Imagine this: vim is running the vimscript garbage collector. Then a
> pyhton thread runs vim.cmd().. It will acquire its lock.. and both, the
> gc and the the python thread will start reading / writing the same
> memory! So this requires kind of global lock anyway. But you know the
> code much better than me. I guess you can just tell me wether such a
> global lock does exist?
>
> It could be fixed easily.. Just acquire the lock when any action is
> triggerd. Sources which can trigger actions: Keyboard/ mouse input and
> script threads such as the python one. Don't know about (perl, ruby,
> ...)
Locks are never easy.
--
If your life is a hard drive,
Christ can be your backup.
/// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ download, build and distribute -- http://www.A-A-P.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---