threading/forking and IPC

Discussion in 'Python' started by Sophia Cao, Oct 14, 2005.

  1. Sophia Cao

    Sophia Cao Guest

    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.
     
    Sophia Cao, Oct 14, 2005
    #1
    1. Advertising

  2. Sophia Cao

    David Wahler Guest

    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
     
    David Wahler, Oct 14, 2005
    #2
    1. Advertising

  3. Sophia Cao

    Qun Cao Guest

    Thanks David,
    This seems like the exact thing I am looking for!
     
    Qun Cao, Oct 15, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. rh0dium

    Fork You.. Forking and threading..

    rh0dium, Jul 5, 2006, in forum: Python
    Replies:
    4
    Views:
    4,013
    rh0dium
    Jul 6, 2006
  2. Replies:
    9
    Views:
    1,132
    Mark Space
    Dec 29, 2007
  3. Steven Woody
    Replies:
    0
    Views:
    478
    Steven Woody
    Jan 9, 2009
  4. Steven Woody
    Replies:
    0
    Views:
    492
    Steven Woody
    Jan 9, 2009
  5. Joerg Diekmann
    Replies:
    0
    Views:
    120
    Joerg Diekmann
    Feb 16, 2006
Loading...

Share This Page