On 8/13/2013 4:06 AM, [email protected] wrote:
Aside from the other comments...
def item_thread(self):
imageAnalyzer=ctypes.CDLL("../so/image_process.so")
imageAnalyzer.aref_img_score_init("/opt/amniran/etc/face.xml",
"/opt/amniran/etc/porn.xml")
for filename in os.listdir("../script/images/"):
if filename[-4:] == ".jpg" or filename[-4:] == ".png" or filename[-4:] ==
".gif" or filename[-5:] == ".jpeg" :
path = "../script/images/%s"%filename
fo = file(path, "r")
Use 'open' instead of the deprecated 'file' (removed in 3.x) and use it
with a 'with' statement (this is now standard). This closes the file at
the end of the block. Not doing so can cause problems on other
implementations.
with open(path, 'rb') as fo:
content = fo.read()
score = imageAnalyzer.score_image(content, len(content))
print "%d : %s " %(score, path)
print "ENDDDDDDDDDDDDDDDDDDDDDDDDDDDD"
Do you know how to use queue.Queue to spread work to multiple worker
threads so each processes different files (and to collect results from
multiple threads).? (If not, read doc.)
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list