Patchwork D3845: worker: support more return types in posix worker

login
register
mail settings
Submitter phabricator
Date July 4, 2018, 12:04 p.m.
Message ID <46a286b0477f30ce1822d6d26ec7ce07@localhost.localdomain>
Download mbox | patch
Permalink /patch/32609/
State Not Applicable
Headers show

Comments

phabricator - July 4, 2018, 12:04 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG8c38d2948217: worker: support more return types in posix worker (authored by hooper, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3845?vs=9418&id=9429

REVISION DETAIL
  https://phab.mercurial-scm.org/D3845

AFFECTED FILES
  mercurial/worker.py

CHANGE DETAILS




To: hooper, #hg-reviewers
Cc: yuja, durin42, mercurial-devel

Patch

diff --git a/mercurial/worker.py b/mercurial/worker.py
--- a/mercurial/worker.py
+++ b/mercurial/worker.py
@@ -155,8 +155,8 @@ 
 
                 def workerfunc():
                     os.close(rfd)
-                    for i, item in func(*(staticargs + (pargs,))):
-                        os.write(wfd, '%d %s\n' % (i, item))
+                    for result in func(*(staticargs + (pargs,))):
+                        os.write(wfd, util.pickle.dumps(result))
                     return 0
 
                 ret = scmutil.callcatch(ui, workerfunc)
@@ -187,9 +187,15 @@ 
                 os.kill(os.getpid(), -status)
             sys.exit(status)
     try:
-        for line in util.iterfile(fp):
-            l = line.split(' ', 1)
-            yield int(l[0]), l[1][:-1]
+        while True:
+            try:
+                yield util.pickle.load(fp)
+            except EOFError:
+                break
+            except IOError as e:
+                if e.errno == errno.EINTR:
+                    continue
+                raise
     except: # re-raises
         killworkers()
         cleanup()