I'm adding more details on the problem...

On Thu, Nov 8, 2012 at 6:21 PM, Jakson Alves de Aquino
<[email protected]> wrote:
> I'm the maintainer of Vim-R-plugin which may start a separate Vim
> instance to run an "Object Browser". This Vim instance has a UDP
> server running in a new thread. The server is written in Python and it
> receives messages from R to update the list of objects. This Vim
> instance isn't used to edit code and thus there is no problem if Vim
> code is executed from the server thread.
>
> Problem: The server stopped working after patch 691. The problem is
> the line 748 of src/if_python.c. If I delete this line, the server
> works as before. The server is created by the function VimServer() of
> https://github.com/jcfaria/Vim-R-plugin/blob/master/r-plugin/vimcom.py

The line 748 of src/if_python.c is:

    pygilstate = PyGILState_Ensure();

The function VimServer() is called by RunServer() which uses the
threading module to create a new thread running VimServer(). The
VimServer() becomes immediately unresponsive. For example, there one
message that the VimServer() function sends to R when the server is
successfully started, but this message is actually being sent only
when the server is joined to the main thread or when the thread is
killed.

It seems that currently it's not possible to run a thread in parallel
to the main Vim process.

> I'm far from an expert in Python programming, and I don't know how to
> solve the problem. Any help is appreciated.

The solutions that I think that may be possible are:

    1) Undo the effect of PyGILState_Ensure() in the vimcom.py code
       (I don't know if this is possible).

    2) Create a Vim option to call/not call PyGILState_Ensure(). That
       is, transfer to plugin developers the option to use or not use
       unsafe threads.

In the Vim-R-plugin, the server is only used when Vim is running
inside a Tmux session and we have two independent Vim instances. I use
the server in the editor instance of Vim only to change the value of a
variable storing the number of the port of the Object Browser server.
In the Object Browser instance of Vim, the server calls functions to
rewrite the content of the buffer but that is almost always done when
the user is editing code in the editor instance and, thus, it's almost
always idle and almost never crashes. And when it does crash, no data
is lost since the Object Browser is not used to edit code.

Thanks

-- 
Jakson Alves de Aquino
Federal University of CearĂ¡
Social Sciences Department
www.lepem.ufc.br/aquino.php

-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Raspunde prin e-mail lui