newbee: Simple Backend Python Script Question
I need to create python script that is threaded. So the main program will run in infinite loop and just retrieving messages and putting them in a queue. (Main thread) I need child threads from a pool to process the queue. When there is no stuff in the queue, they go to the pool and become available but they don't terminate. This has to be done continuously. Main program need to keep putting stuff in the queue, when there are no messages, then it sleeps for short time and check back to see any messages. To do this, I guess you don't write joinAll(), so that the main threads just don't wait for the child but goes to work. am I right? Also, child threads (a function that is threaded) will make connecitons to the database. I am planning to use threadpool, so that threads reuse the connections. So do you close the database connection at the end of the function? If not then the connection will be opened forever? Joe -- http://mail.python.org/mailman/listinfo/python-list
MD5 hash for url and utf unicode converting to ascii
I would like to convert url into md5 hash. My question is that md5 hash will create collision at 2^64. If you do long(value,16), where value is the md5 hash string, would value returned from long(value, 16) be unique as long as md5 hashed string is unique? when you move md5 hashed string to long, where will the collision occur, at anything >= 2^64? hash = md5.new() hash.update("some_url_") value = hash.digest() value_in_int = long(value, 16) #would this be unique as long as hashed string is unique(i.e < 2^64) hash = md5.new() hash.update("some_url_") value = hash.digest() value_in_int = long(value, 16) #would this be unique as long as hashed string is unique(i.e < 2^64) Do I need to also convert the value to base64.encodestring(value)? What is the purpose of base64.encodestring? For unicode encoding, I can do, md5.update(value.encode('utf-8')) to give me ascii values. Thank you, j -- http://mail.python.org/mailman/listinfo/python-list
Python pack and unpack question
If you have the following: data = unpack('>L', sock.recv(4)) Does this line of code means that incoming data is big endian and unpack it to endianess of local machine? If local machine is little endian, then big endian is automatically converted to little endian format? thank you. -- http://mail.python.org/mailman/listinfo/python-list