Patch 8.2.4250
Problem:    Channel out callback test is flaky on Mac.
Solution:   Assign high priority to the test process. (Ozaki Kiichi,
            closes #9653)
Files:      src/testdir/test_channel_pipe.py, src/testdir/thread_util.py


*** ../vim-8.2.4249/src/testdir/test_channel_pipe.py    2020-05-06 
18:37:48.524006767 +0100
--- src/testdir/test_channel_pipe.py    2022-01-29 12:04:03.098818956 +0000
***************
*** 5,10 ****
--- 5,11 ----
  # This requires Python 2.6 or later.
  
  from __future__ import print_function
+ import os
  import sys
  import time
  
***************
*** 27,32 ****
--- 28,40 ----
              if sys.argv[1].startswith("quit"):
                  sys.exit(0)
  
+     if os.getenv('CI'):
+         try:
+             import thread_util
+             thread_util.set_high_priority()
+         except Exception:
+             pass
+ 
      while True:
          typed = sys.stdin.readline()
          if typed == "":  # EOF -- stop
*** ../vim-8.2.4249/src/testdir/thread_util.py  2022-01-29 12:07:50.283711540 
+0000
--- src/testdir/thread_util.py  2022-01-29 12:04:03.098818956 +0000
***************
*** 0 ****
--- 1,90 ----
+ import platform
+ 
+ if platform.system() == 'Darwin':
+     from ctypes import (
+         CDLL,
+         POINTER,
+         Structure,
+         byref,
+         c_int,
+         c_uint,
+         c_uint32,
+         c_void_p,
+         sizeof
+     )
+     from ctypes.util import find_library
+ 
+     class ThreadTimeConstraintPolicy(Structure):
+         _fields_ = [
+             ("period", c_uint32),
+             ("computation", c_uint32),
+             ("constraint", c_uint32),
+             ("preemptible", c_uint)
+         ]
+ 
+     _libc = CDLL(find_library('c'))
+ 
+     THREAD_TIME_CONSTRAINT_POLICY = c_uint(2)
+ 
+     THREAD_TIME_CONSTRAINT_POLICY_COUNT = c_uint(
+         int(sizeof(ThreadTimeConstraintPolicy) / sizeof(c_int)))
+ 
+     _libc.pthread_self.restype = c_void_p
+ 
+     _libc.pthread_mach_thread_np.restype = c_uint
+     _libc.pthread_mach_thread_np.argtypes = [c_void_p]
+ 
+     _libc.thread_policy_get.restype = c_int
+     _libc.thread_policy_get.argtypes = [
+         c_uint,
+         c_uint,
+         c_void_p,
+         POINTER(c_uint),
+         POINTER(c_uint)
+     ]
+ 
+     _libc.thread_policy_set.restype = c_int
+     _libc.thread_policy_set.argtypes = [
+         c_uint,
+         c_uint,
+         c_void_p,
+         c_uint
+     ]
+ 
+     def _mach_thread_self():
+         return _libc.pthread_mach_thread_np(_libc.pthread_self())
+ 
+     def _get_time_constraint_policy(default=False):
+         thread = _mach_thread_self()
+         policy_info = ThreadTimeConstraintPolicy()
+         policy_infoCnt = THREAD_TIME_CONSTRAINT_POLICY_COUNT
+         get_default = c_uint(default)
+ 
+         kret = _libc.thread_policy_get(
+             thread,
+             THREAD_TIME_CONSTRAINT_POLICY,
+             byref(policy_info),
+             byref(policy_infoCnt),
+             byref(get_default))
+         if kret != 0:
+             return None
+         return policy_info
+ 
+     def _set_time_constraint_policy(policy_info):
+         thread = _mach_thread_self()
+         policy_infoCnt = THREAD_TIME_CONSTRAINT_POLICY_COUNT
+ 
+         kret = _libc.thread_policy_set(
+             thread,
+             THREAD_TIME_CONSTRAINT_POLICY,
+             byref(policy_info),
+             policy_infoCnt)
+         if kret != 0:
+             raise OSError(kret)
+ 
+     def set_high_priority():
+         policy_info = _get_time_constraint_policy(default=True)
+         if not policy_info:
+             return
+         policy_info.preemptible = c_uint(False)
+         _set_time_constraint_policy(policy_info)
*** ../vim-8.2.4249/src/version.c       2022-01-29 11:22:11.827641991 +0000
--- src/version.c       2022-01-29 12:06:21.788926998 +0000
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     4250,
  /**/

-- 
CART DRIVER: Bring out your dead!
   We follow the cart through a wretched, impoverished plague-ridden village.
   A few starved mongrels run about in the mud scavenging.  In the open
   doorway of one house perhaps we jug glimpse a pair of legs dangling from
   the ceiling.  In another doorway an OLD WOMAN is beating a cat against a
   wall rather like one does with a mat.  The cart passes round a dead donkey
   or cow in the mud.  And a MAN tied to a cart is being hammered to death by
   four NUNS with huge mallets.
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20220129121115.A74C21C1918%40moolenaar.net.

Raspunde prin e-mail lui