[Python-Dev] threadsafe patch for asynchat (original) (raw)
Mark Edgington edgimar at lycos.com
Sun Feb 5 22:26:48 CET 2006
- Previous message: [Python-Dev] Let's just *keep* lambda
- Next message: [Python-Dev] threadsafe patch for asynchat
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Does anyone have any comments about applying the following patch to asynchat? It should not affect the behavior of the module in any way for those who do not want to use the feature provided by the patch. The point of the patch is to make it easy to use asynchat in a multithreaded application. Maybe I am missing something, and the patch really doesn't make it threadsafe? Any comments would be appreciated. Also, if it looks good to everyone, feel free to use it.
-------BEGIN PATCH---------- --- asynchat.py Fri Oct 15 03:03:16 2004 +++ asynchat.py.new Sun Feb 05 22:05:42 2006 @@ -59,10 +59,11 @@ ac_in_buffer_size = 4096 ac_out_buffer_size = 4096
- def init (self, conn=None):
- def init (self, conn=None, running_in_thread=False): self.ac_in_buffer = '' self.ac_out_buffer = '' self.producer_fifo = fifo()
def collect_incoming_data(self, data):self.running_in_thread = runnning_in_thread asyncore.dispatcher.__init__ (self, conn)
@@ -157,7 +158,9 @@
def push (self, data):
self.producer_fifo.push (simple_producer (data))self.initiate_send()
# only initiate a send if not running in a threaded
environment, since
# initiate_send() is not threadsafe.
def push_with_producer (self, producer): self.producer_fifo.push (producer)if not self.running_in_thread: self.initiate_send()
-------END PATCH----------
-Mark
- Previous message: [Python-Dev] Let's just *keep* lambda
- Next message: [Python-Dev] threadsafe patch for asynchat
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]