Loading ...
Sorry, an error occurred while loading the content.

Re: Thread safety not mentioned for python bindings

Expand Messages
  • Zhao Cai
    I tried to make some vim function calls from python thread. Some of the functions like `taglist()` are working but I am not sure if it is safe. Can anyone who
    Message 1 of 4 , May 19, 2013
    • 0 Attachment
      I tried to make some vim function calls from python thread. Some of the functions like `taglist()` are working but I am not sure if it is safe. Can anyone who knows this part of code give an "official" answer? Thanks!

      On Oct 24, 2012, at 4:57 PM, Timothy Madden <terminatorul@...> wrote:

      > Hello
      >
      > I read the python bindings help file (if_python.txt) and I found nothing about thread safety. Although Vim itself does not use threads, the invoked python code can create them and than the main thread can return control to Vim normally. I would like to write a plug-in that listens to a TCP connection in the background, and somehow notifies Vim when new data arrives on the socket.
      >
      > Now, since the documentation says nothing about it, I would assume the python language bindings are not thread-safe, or even if they are thread-safe, that is still an undocumented feature. But does anyone have more specific information please ? Has anyone tried working with treads from python code in Vim ? Can the help file be updated to mention this aspect ?
      >
      > Thank you,
      > Timothy Madden
      >
      > --
      > You received this message from the "vim_use" 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

      --
      --
      You received this message from the "vim_use" 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

      ---
      You received this message because you are subscribed to the Google Groups "vim_use" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • ZyX ZyX
      ... functions like `taglist()` are working but I am not sure if it is safe. Can anyone who knows this part of code give an official answer? Thanks! This code
      Message 2 of 4 , May 29, 2013
      • 0 Attachment


        On May 19, 2013 5:01 PM, "Zhao Cai" <zhaocai@...> wrote:
        >
        > I tried to make some vim function calls from python thread. Some of the functions like `taglist()` are working but I am not sure if it is safe. Can anyone who knows this part of code give an "official" answer? Thanks!

        This code is not thread-safe. Vim is using globals for a large variety of purposes and it is better not to run any code from non-main thread. User-defined functions are the worst candidates for such call; with built-in ones you will be lucky more more often, but still it is better to avoid calling vim from the separate thread.

        In if_py_both there are some functions which as far as I see are a placeholders for Vim GIL, but they are only the placeholders lacking actual implementation in vim core (and if there was GIL if_py_both.h is a wrong place to define such functions). And they are not used in code I added.

        > On Oct 24, 2012, at 4:57 PM, Timothy Madden <terminatorul@...> wrote:
        >
        > > Hello
        > >
        > > I read the python bindings help file (if_python.txt) and I found nothing about thread safety. Although Vim itself does not use threads, the invoked python code can create them and than the main thread can return control to Vim normally. I would like to write a plug-in that listens to a TCP connection in the background, and somehow notifies Vim when new data arrives on the socket.
        > >
        > > Now, since the documentation says nothing about it, I would assume the python language bindings are not thread-safe, or even if they are thread-safe, that is still an undocumented feature. But does anyone have more specific information please ? Has anyone tried working with treads from python code in Vim ? Can the help file be updated to mention this aspect ?
        > >
        > > Thank you,
        > > Timothy Madden
        > >
        > > --
        > > You received this message from the "vim_use" 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
        >
        > --
        > --
        > You received this message from the "vim_use" 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
        >
        > ---
        > You received this message because you are subscribed to the Google Groups "vim_use" group.
        > To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
        > For more options, visit https://groups.google.com/groups/opt_out.
        >
        >

        --
        --
        You received this message from the "vim_use" 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
         
        ---
        You received this message because you are subscribed to the Google Groups "vim_use" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
         
         
      Your message has been successfully submitted and would be delivered to recipients shortly.