Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > threading/forking and IPC

Reply
Thread Tools

threading/forking and IPC

 
 
Sophia Cao
Guest
Posts: n/a
 
      10-14-2005
Hello,

I am seeking a python solution for my project. I am trying to
implement an architecture where there is a server who receives incoming
messages from several clients, then those messages need to be written
to a MySQL database. To avoid too many connections to the database, I
plan to save the incoming messages into a queue, while use a seperate
process/thread to constantly monitoring the queue and storing the
messages to the database. I am not sure wheather I should use
threading or forking and how to implement the sharing of this message
queue.

Thanks a lot for any advice.

 
Reply With Quote
 
 
 
 
David Wahler
Guest
Posts: n/a
 
      10-14-2005

Sophia Cao wrote:
> Hello,
>
> I am seeking a python solution for my project. I am trying to
> implement an architecture where there is a server who receives incoming
> messages from several clients, then those messages need to be written
> to a MySQL database. To avoid too many connections to the database, I
> plan to save the incoming messages into a queue, while use a seperate
> process/thread to constantly monitoring the queue and storing the
> messages to the database. I am not sure wheather I should use
> threading or forking and how to implement the sharing of this message
> queue.
>
> Thanks a lot for any advice.


If you want to have a shared queue, it's much easier and simpler to use
threading, as it allows you to share data structures between threads.
Python already has a multithreaded queue class -- see
http://docs.python.org/lib/module-Queue.html. Just create a global
Queue object or pass each thread a reference to it, and they can all
share it.

-- David

 
Reply With Quote
 
 
 
 
Qun Cao
Guest
Posts: n/a
 
      10-14-2005
Thanks David,
This seems like the exact thing I am looking for!

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
about daemons and IPC sdistefano@gmail.com Python 4 08-29-2006 05:36 PM
Cross Platform Plug-in architecture and IPC Paul Tremblay C++ 1 06-16-2005 01:29 PM
Another newbie question re: STDERR and IPC::open3(), nowait() and zombies Dave Newberry Perl 0 10-17-2004 06:41 PM
IPC::Run and hanging pipes Brian Hann Perl 1 12-11-2003 08:41 PM
open, ipc, and return codes gary Perl 3 09-18-2003 12:17 AM



Advertisments