Fucking Gmail.
---------- Forwarded message ---------- From: Bryan Tong Minh bryan.tongminh@gmail.com Date: Nov 6, 2007 6:17 PM Subject: Re: [Pywikipedia-l] Rewrite thoughts (includes replies to the 4507-thread) To: Merlijn van Deen valhallasw@arctus.nl
On Nov 6, 2007 4:41 PM, Merlijn van Deen valhallasw@arctus.nl wrote:
Also the use of persistent HTTP connections makes the framework less fool proof. Persistent HTTP connections makes an object that uses them automatically unsuitable for sharing between threads.
Is that so? A quick sketchup:
page.get(): lock = threading.Lock() #thread safe lock lock.acquire() page_get_queue.append((self, query, lock)) lock.acquire(1)
with the page getter releasing the lock. But I am probably ignoring some important thread safety now :)
The whole point is that the common file object that is associated with the connection is shared between threads. For example, this will happen:
def thread1(self): self.sock.sendall('GET / HTTP/1.0\r\n') self.sock.sendall('\r\n') return self.sock.recv(1024) thread.start_new_thread(thread1) thread1()
Hell will break lose.
Bryan