Re: how can a child thread notify a parent thread its status?

2009-07-25 Thread scriptlear...@gmail.com
I decided to go with one big log file, which will be shared by all threads (child and parent). A log message Queue is used to store all log entries, and a customized logger thread will get log entries from the Queue. #from the logger thread# def run(self): while self.flag == 1: #if th

Re: how can a child thread notify a parent thread its status?

2009-07-25 Thread scriptlear...@gmail.com
First of all, let me say thank you to all of you. I have asked many questions (some of them are dump questions), and you have kindly helped me. I am not going to reply every message to say thank-you since that would be annoying for such group with such high daily traffics. Thank you very much.

time in milliseconds by calling time.time()

2009-07-24 Thread scriptlear...@gmail.com
I am trying to measure some system response time by using the time.time () or time.clock() in my script. However, the numbers I get are in 10s of milliseconds. For example, 1248481670.34 #from time.time() 0.08 #from time.clock() That won't work for me, since the response time

how can a child thread notify a parent thread its status?

2009-07-24 Thread scriptlear...@gmail.com
My parent thread keeps a counter for the number of free child workers (say 100) and initializes some child threads and call child.start(). Once the number of free child workers reach 0, the parent thread will wait until some at least one child thread finishes and then it will initialize another chi

passing data to a liburl2 opener object

2009-07-23 Thread scriptlear...@gmail.com
I have prepared my headers and data for a HTTP POST message; however, I am not sure how to pass the data to the opener. Can you guys provide some suggestions? Thanks. proxy_handler = urllib2.ProxyHandler({'http': 'http://my.proxy.com: 3128/'}) opener = urllib2.build_opener(proxy_handler) url =

regex: multiple matching for one string

2009-07-22 Thread scriptlear...@gmail.com
For example, I have a string "#a=valuea;b=valueb;c=valuec;", and I will like to take out the values (valuea, valueb, and valuec). How do I do that in Python? The group method will only return the matched part. Thanks. p = re.compile('#a=*;b=*;c=*;') m = p.match(line) if m:

Re: logging outgoing HTTP POST message and incoming response message

2009-07-22 Thread scriptlear...@gmail.com
On Jul 22, 1:54 pm, "Diez B. Roggisch" wrote: > You can use proxy-tools such as tcpmon or sniff traffic using wireshark. > > Diez Thanks, but I am trying to enable some debug mode to log all outgoing and incoming messages for certain period of time, and running another proxy-tool is not very idea

logging outgoing HTTP POST message and incoming response message

2009-07-22 Thread scriptlear...@gmail.com
I am sending a HTTP POST by using the following codes: opener = urllib2.build_opener(proxyHandler, MultipartPostHandler) params = { "audio" : "http://sample.com/my.wav";, "data" : open(file, "rb") } print opener.open(myURL, params).read() How do I log or print out the actual POST message (includi

Looking for the right library for a simple HTTP client

2009-07-09 Thread scriptlear...@gmail.com
I am trying to implement a simple client that can do the following: 1)to send the following kinds of HTTP requests and validate responses 1.1 GET 1.2 POST with application/x-www-form-urlencoded encoding 1.3 POST with multipart/form-data encoding 2)to set any number of (even duplicate) headers. Fo