Mageia Bugzilla – Attachment 4178 Details for
Bug 952
mgarepo up doesn't handle conflicts well
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
New Account
|
Forgot Password
[patch]
Poll pipe in noblocking mode
mga-repo-hang-fix.patch (text/plain), 1.77 KB, created by
Dan Fandrich
on 2013-06-30 02:48:18 CEST
(
hide
)
Description:
Poll pipe in noblocking mode
Filename:
MIME Type:
Creator:
Dan Fandrich
Created:
2013-06-30 02:48:18 CEST
Size:
1.77 KB
patch
obsolete
>Index: MgaRepo/util.py >=================================================================== >--- MgaRepo/util.py (revision 8580) >+++ MgaRepo/util.py (working copy) >@@ -7,6 +7,9 @@ > import sys > import os > import re >+import fcntl >+import errno >+import select > from cStringIO import StringIO > import httplib2 > #import commands >@@ -34,14 +37,31 @@ > stdin=pstdin) > of = pipe.stdout.fileno() > ef = pipe.stderr.fileno() >+ fcntl.fcntl(of, fcntl.F_SETFL, fcntl.fcntl(of, fcntl.F_GETFL) | os.O_NONBLOCK) >+ fcntl.fcntl(ef, fcntl.F_SETFL, fcntl.fcntl(ef, fcntl.F_GETFL) | os.O_NONBLOCK) > while True: >- odata = os.read(of, 8192) >- sys.stdout.write(odata) >- edata = os.read(ef, 8192) >- err.write(edata) >- sys.stderr.write(edata) >+ r,w,x = select.select((of,ef), (), (of,ef)) >+ try: >+ odata = os.read(of, 8192) >+ except OSError, e: >+ if e.errno != errno.EWOULDBLOCK: >+ raise >+ odata = None >+ else: >+ sys.stdout.write(odata) >+ >+ try: >+ edata = os.read(ef, 8192) >+ except OSError, e: >+ if e.errno != errno.EWOULDBLOCK: >+ raise >+ edata = None >+ else: >+ err.write(edata) >+ sys.stderr.write(edata) >+ > status = pipe.poll() >- if status is not None and not (odata and edata): >+ if status is not None and odata == "" and edata == "": > break > output = err.getvalue() > else:
Index: MgaRepo/util.py =================================================================== --- MgaRepo/util.py (revision 8580) +++ MgaRepo/util.py (working copy) @@ -7,6 +7,9 @@ import sys import os import re +import fcntl +import errno +import select from cStringIO import StringIO import httplib2 #import commands @@ -34,14 +37,31 @@ stdin=pstdin) of = pipe.stdout.fileno() ef = pipe.stderr.fileno() + fcntl.fcntl(of, fcntl.F_SETFL, fcntl.fcntl(of, fcntl.F_GETFL) | os.O_NONBLOCK) + fcntl.fcntl(ef, fcntl.F_SETFL, fcntl.fcntl(ef, fcntl.F_GETFL) | os.O_NONBLOCK) while True: - odata = os.read(of, 8192) - sys.stdout.write(odata) - edata = os.read(ef, 8192) - err.write(edata) - sys.stderr.write(edata) + r,w,x = select.select((of,ef), (), (of,ef)) + try: + odata = os.read(of, 8192) + except OSError, e: + if e.errno != errno.EWOULDBLOCK: + raise + odata = None + else: + sys.stdout.write(odata) + + try: + edata = os.read(ef, 8192) + except OSError, e: + if e.errno != errno.EWOULDBLOCK: + raise + edata = None + else: + err.write(edata) + sys.stderr.write(edata) + status = pipe.poll() - if status is not None and not (odata and edata): + if status is not None and odata == "" and edata == "": break output = err.getvalue() else:
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 952
:
4178
|
4179