mercurial/worker.py
changeset 48870 df56e6bd37f6
parent 46819 d4ba4d51f85f
child 48875 6000f5b25c9b
equal deleted inserted replaced
48869:57b58413dad1 48870:df56e6bd37f6
     7 
     7 
     8 from __future__ import absolute_import
     8 from __future__ import absolute_import
     9 
     9 
    10 import errno
    10 import errno
    11 import os
    11 import os
       
    12 import pickle
    12 import signal
    13 import signal
    13 import sys
    14 import sys
    14 import threading
    15 import threading
    15 import time
    16 import time
    16 
    17 
    25 from . import (
    26 from . import (
    26     encoding,
    27     encoding,
    27     error,
    28     error,
    28     pycompat,
    29     pycompat,
    29     scmutil,
    30     scmutil,
    30     util,
       
    31 )
    31 )
    32 
    32 
    33 
    33 
    34 def countcpus():
    34 def countcpus():
    35     '''try to count the number of CPUs on the system'''
    35     '''try to count the number of CPUs on the system'''
   254                     for r, w in pipes[:-1]:
   254                     for r, w in pipes[:-1]:
   255                         os.close(r)
   255                         os.close(r)
   256                         os.close(w)
   256                         os.close(w)
   257                     os.close(rfd)
   257                     os.close(rfd)
   258                     for result in func(*(staticargs + (pargs,))):
   258                     for result in func(*(staticargs + (pargs,))):
   259                         os.write(wfd, util.pickle.dumps(result))
   259                         os.write(wfd, pickle.dumps(result))
   260                     return 0
   260                     return 0
   261 
   261 
   262                 ret = scmutil.callcatch(ui, workerfunc)
   262                 ret = scmutil.callcatch(ui, workerfunc)
   263         except:  # parent re-raises, child never returns
   263         except:  # parent re-raises, child never returns
   264             if os.getpid() == parentpid:
   264             if os.getpid() == parentpid:
   290     try:
   290     try:
   291         openpipes = len(pipes)
   291         openpipes = len(pipes)
   292         while openpipes > 0:
   292         while openpipes > 0:
   293             for key, events in selector.select():
   293             for key, events in selector.select():
   294                 try:
   294                 try:
   295                     res = util.pickle.load(_blockingreader(key.fileobj))
   295                     res = pickle.load(_blockingreader(key.fileobj))
   296                     if hasretval and res[0]:
   296                     if hasretval and res[0]:
   297                         retval.update(res[1])
   297                         retval.update(res[1])
   298                     else:
   298                     else:
   299                         yield res
   299                         yield res
   300                 except EOFError:
   300                 except EOFError: