Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 704161 Details for
Bug 916562
'createrepo -v' deadlocks on large repositories
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
Better example of why mixing select and readline is bad
tmp.py (text/plain), 2.53 KB, created by
Anders Blomdell
on 2013-03-01 13:50:42 UTC
(
hide
)
Description:
Better example of why mixing select and readline is bad
Filename:
MIME Type:
Creator:
Anders Blomdell
Created:
2013-03-01 13:50:42 UTC
Size:
2.53 KB
patch
obsolete
>#! /usr/bin/python > >import select >import threading >import os >import time > >def start_producer(): > def producer(f1, f2): > print>>f1,'Lock consumer on read 1', > f1.flush() > time.sleep(1) > for n in range(4): > print>>f2,n > f2.flush() > pass > print>>f1,', let it loose, line 1 from fd2 will be read' > f1.flush() > time.sleep(5) > print>>f1,'now all lines will be read' > f1.close() > f2.close() > pass > > r1,w1 = os.pipe() > r2,w2 = os.pipe() > r1 = os.fdopen(r1) > r2 = os.fdopen(r2) > t1 = threading.Thread(target=producer, > args=((os.fdopen(w1, 'w'), os.fdopen(w2, 'w')))) > t1.daemon =True > t1.start() > return r1,r2 > >def mixing_high_and_low_level_is_bad(): > print 'mixing_high_and_low_level_is_bad' > r1,r2 = start_producer() > gimmebreak = 0 > while gimmebreak != 2: > gimmebreak = 0 > readable,_,_ = select.select([r1, r2],[],[], 1) > time.sleep(0.1) > if r1 in readable: > line = r1.readline() > if len(line) == 0: > gimmebreak += 1 > pass > else: > print 'r1:',line.strip() > pass > if r2 in readable: > line = r2.readline() > if len(line) == 0: > gimmebreak += 1 > pass > else: > print 'r2:',line.strip() > pass > pass > pass > print > pass > >def all_low_level_is_better(): > print 'all_low_level_is_better' > r1,r2 = start_producer() > gimmebreak = 0 > buffer = {} > buffer[r1] = '' > buffer[r2] = '' > while gimmebreak != 2: > gimmebreak = 0 > readable,_,_ = select.select([r1, r2],[],[], 1) > for r in readable: > line = os.read(r.fileno(), 4096) > if len(line) == 0: > gimmebreak += 1 > pass > else: > buffer[r] += line > pass > pass > if '\n' in buffer[r1]: > line,buffer[r1] = buffer[r1].split('\n', 1) > if len(line) != 0: > print 'r1:',line.strip() > pass > pass > if '\n' in buffer[r2]: > line,buffer[r2] = buffer[r2].split('\n', 1) > if len(line) != 0: > print 'r2:',line.strip() > pass > pass > pass > print > pass > >if __name__ == '__main__': > mixing_high_and_low_level_is_bad() > all_low_level_is_better()
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 916562
:
703876
|
703907
|
703910
|
703925
| 704161 |
704222