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

Patch 7.3.786

Expand Messages
  • Bram Moolenaar
    Patch 7.3.786 Problem: Python threads don t run in the background (issue 103). Solution: Move the statements to manipulate thread state. Files:
    Message 1 of 7 , Jan 30, 2013
    • 0 Attachment
      Patch 7.3.786
      Problem: Python threads don't run in the background (issue 103).
      Solution: Move the statements to manipulate thread state.
      Files: src/if_python.c


      *** ../vim-7.3.785/src/if_python.c 2012-10-21 01:46:56.000000000 +0200
      --- src/if_python.c 2013-01-30 11:38:06.000000000 +0100
      ***************
      *** 740,751 ****
      #else
      PyMac_Initialize();
      #endif
      ! /* Initialise threads, and save the state using PyGILState_Ensure.
      ! * Without the call to PyGILState_Ensure, thread specific state (such
      ! * as the system trace hook), will be lost between invocations of
      ! * Python code. */
      PyEval_InitThreads();
      - pygilstate = PyGILState_Ensure();
      #ifdef DYNAMIC_PYTHON
      get_exceptions();
      #endif
      --- 740,750 ----
      #else
      PyMac_Initialize();
      #endif
      ! /* Initialise threads, and below save the state using
      ! * PyGILState_Ensure. Without the call to PyGILState_Ensure, thread
      ! * specific state (such as the system trace hook), will be lost
      ! * between invocations of Python code. */
      PyEval_InitThreads();
      #ifdef DYNAMIC_PYTHON
      get_exceptions();
      #endif
      ***************
      *** 756,761 ****
      --- 755,764 ----
      if (PythonMod_Init())
      goto fail;

      + /* The first python thread is vim's, release the lock. */
      + Python_SaveThread();
      + pygilstate = PyGILState_Ensure();
      +
      globals = PyModule_GetDict(PyImport_AddModule("__main__"));

      /* Remove the element from sys.path that was added because of our
      ***************
      *** 764,771 ****
      * the current directory in sys.path. */
      PyRun_SimpleString("import sys; sys.path = filter(lambda x: x != '/must>not&exist', sys.path)");

      ! /* the first python thread is vim's, release the lock */
      ! Python_SaveThread();

      initialised = 1;
      }
      --- 767,773 ----
      * the current directory in sys.path. */
      PyRun_SimpleString("import sys; sys.path = filter(lambda x: x != '/must>not&exist', sys.path)");

      ! PyGILState_Release(pygilstate);

      initialised = 1;
      }
      *** ../vim-7.3.785/src/version.c 2013-01-25 20:10:58.000000000 +0100
      --- src/version.c 2013-01-30 11:44:04.000000000 +0100
      ***************
      *** 727,728 ****
      --- 727,730 ----
      { /* Add new patch number below this line */
      + /**/
      + 786,
      /**/

      --
      ARTHUR: I command you as King of the Britons to stand aside!
      BLACK KNIGHT: I move for no man.
      The Quest for the Holy Grail (Monty Python)

      /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
      /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
      \\\ an exciting new programming language -- http://www.Zimbu.org ///
      \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

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

      ---
      You received this message because you are subscribed to the Google Groups "vim_dev" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Ken Takata
      Hi, ... There is the same problem with if_python3. ... +++ b/src/if_python3.c @@ -734,6 +734,8 @@ * as the system trace hook), will be lost between invocations
      Message 2 of 7 , Jan 30, 2013
      • 0 Attachment
        Hi,

        Bram Moolenaar wrote:

        > Patch 7.3.786
        > Problem: Python threads don't run in the background (issue 103).
        > Solution: Move the statements to manipulate thread state.
        > Files: src/if_python.c

        There is the same problem with if_python3.
        Following patch seems to fix this (but I'm not sure):

        --- a/src/if_python3.c
        +++ b/src/if_python3.c
        @@ -734,6 +734,8 @@
        * as the system trace hook), will be lost between invocations of
        * Python code. */
        PyEval_InitThreads();
        + /* The first python thread is vim's, release the lock. */
        + PyGILState_Release(pygilstate);
        pygilstate = PyGILState_Ensure();

        #ifdef DYNAMIC_PYTHON3


        Thanks,
        Ken Takata

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

        ---
        You received this message because you are subscribed to the Google Groups "vim_dev" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
      • Bram Moolenaar
        ... That doesn t look right, it would access pygilstate before setting it. -- If your life is a hard drive, Christ can be your backup. /// Bram Moolenaar --
        Message 3 of 7 , Jan 30, 2013
        • 0 Attachment
          Ken Takata wrote:

          > Bram Moolenaar wrote:
          >
          > > Patch 7.3.786
          > > Problem: Python threads don't run in the background (issue 103).
          > > Solution: Move the statements to manipulate thread state.
          > > Files: src/if_python.c
          >
          > There is the same problem with if_python3.
          > Following patch seems to fix this (but I'm not sure):
          >
          > --- a/src/if_python3.c
          > +++ b/src/if_python3.c
          > @@ -734,6 +734,8 @@
          > * as the system trace hook), will be lost between invocations of
          > * Python code. */
          > PyEval_InitThreads();
          > + /* The first python thread is vim's, release the lock. */
          > + PyGILState_Release(pygilstate);
          > pygilstate = PyGILState_Ensure();
          >
          > #ifdef DYNAMIC_PYTHON3

          That doesn't look right, it would access pygilstate before setting it.

          --
          If your life is a hard drive,
          Christ can be your backup.

          /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
          /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
          \\\ an exciting new programming language -- http://www.Zimbu.org ///
          \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

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

          ---
          You received this message because you are subscribed to the Google Groups "vim_dev" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
          For more options, visit https://groups.google.com/groups/opt_out.
        • Ken Takata
          ... Hmm, but the same can be said of if_python.c. pygilstate would be accessed in Python_SaveThread() because PY_CAN_RECURSE is normally defined. Using
          Message 4 of 7 , Jan 31, 2013
          • 0 Attachment
            2013/01/31 Thu 5:56:41 UTC+9 Bram Moolenaar wrote:

            > That doesn't look right, it would access pygilstate before setting it.

            Hmm, but the same can be said of if_python.c. pygilstate would be
            accessed in Python_SaveThread() because PY_CAN_RECURSE is normally defined.

            Using PyEval_SaveThread() to release the GIL seems good.
            I checked the attached patch with Python 2.7 and 3.3 on Win7.
            Both background threads and system trace seem to work well.

            Thanks,
            Ken Takata

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

            ---
            You received this message because you are subscribed to the Google Groups "vim_dev" group.
            To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
            For more options, visit https://groups.google.com/groups/opt_out.
          • Bram Moolenaar
            ... The implementaiton for Python 2 was supposed to work. I would appreciate a few people to try this out on different environments. If I don t hear about
            Message 5 of 7 , Feb 1, 2013
            • 0 Attachment
              Ken Takata wrote:

              > 2013/01/31 Thu 5:56:41 UTC+9 Bram Moolenaar wrote:
              >
              > > That doesn't look right, it would access pygilstate before setting it.
              >
              > Hmm, but the same can be said of if_python.c. pygilstate would be
              > accessed in Python_SaveThread() because PY_CAN_RECURSE is normally defined.
              >
              > Using PyEval_SaveThread() to release the GIL seems good.
              > I checked the attached patch with Python 2.7 and 3.3 on Win7.
              > Both background threads and system trace seem to work well.

              The implementaiton for Python 2 was supposed to work.

              I would appreciate a few people to try this out on different
              environments. If I don't hear about problems I'll include this patch.

              --
              ARTHUR: Listen, old crone! Unless you tell us where we can buy a shrubbery,
              my friend and I will ... we will say "Ni!"
              CRONE: Do your worst!
              "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

              /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
              /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
              \\\ an exciting new programming language -- http://www.Zimbu.org ///
              \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

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

              ---
              You received this message because you are subscribed to the Google Groups "vim_dev" group.
              To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
              For more options, visit https://groups.google.com/groups/opt_out.
            • Ken Takata
              Hi, ... No one has reported about my patch :-( BTW, I wrote tests for the patches 7.3.691, 698 and 768. I found that the patch 7.3.768 breaks 7.3.691. I also
              Message 6 of 7 , Feb 13, 2013
              • 0 Attachment
                Hi,

                2013/02/02 Sat 4:23:57 UTC+9 Bram Moolenaar wrote:

                > The implementaiton for Python 2 was supposed to work.
                >
                > I would appreciate a few people to try this out on different
                > environments. If I don't hear about problems I'll include this patch.

                No one has reported about my patch :-(

                BTW, I wrote tests for the patches 7.3.691, 698 and 768.
                I found that the patch 7.3.768 breaks 7.3.691.
                I also tested my patches with Python 2.7 and 3.2 on Linux and Cygwin.
                Both the background thread and sys.settrace worked fine.

                Regards,
                Ken Takata

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

                ---
                You received this message because you are subscribed to the Google Groups "vim_dev" group.
                To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
                For more options, visit https://groups.google.com/groups/opt_out.
              • Bram Moolenaar
                ... Thanks. I verified the test breaks without including your patch of two weeks ago. I ll send it out now. -- Software is like sex... it s better when it s
                Message 7 of 7 , Feb 13, 2013
                • 0 Attachment
                  Ken Takata wrote:

                  > 2013/02/02 Sat 4:23:57 UTC+9 Bram Moolenaar wrote:
                  >
                  > > The implementaiton for Python 2 was supposed to work.
                  > >
                  > > I would appreciate a few people to try this out on different
                  > > environments. If I don't hear about problems I'll include this patch.
                  >
                  > No one has reported about my patch :-(
                  >
                  > BTW, I wrote tests for the patches 7.3.691, 698 and 768.
                  > I found that the patch 7.3.768 breaks 7.3.691.
                  > I also tested my patches with Python 2.7 and 3.2 on Linux and Cygwin.
                  > Both the background thread and sys.settrace worked fine.

                  Thanks. I verified the test breaks without including your patch of two
                  weeks ago. I'll send it out now.

                  --
                  "Software is like sex... it's better when it's free."
                  -- Linus Torvalds, initiator of the free Linux OS
                  Makes me wonder what FSF stands for...?

                  /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
                  /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
                  \\\ an exciting new programming language -- http://www.Zimbu.org ///
                  \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

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

                  ---
                  You received this message because you are subscribed to the Google Groups "vim_dev" group.
                  To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+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.