473,326 Members | 2,175 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

threading/forking and IPC

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.

Oct 14 '05 #1
2 2418

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

Oct 14 '05 #2
Thanks David,
This seems like the exact thing I am looking for!

Oct 14 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Jane Austine | last post by:
As far as I know python's threading module models after Java's. However, I can't find something equivalent to Java's interrupt and isInterrupted methods, along with InterruptedException....
0
by: Eric S. Johansson | last post by:
I was working on a filter for postfix and instead of using the "fork a new python process on every message" route, I decided to use the SMTP interface instead and try forking after having started...
0
by: SRam | last post by:
I a writing Forking Server for a Small application.. This is code for multiplexing my $listen = IO::Socket::INET->new(Proto => 'tcp',LocalPort => 2323, Listen => 1, Reuse => 1) or die $!; ...
4
by: Lionel van den Berg | last post by:
Hi all, I'm just wondering what's the best option for threading in C++? I've used pthreads and forking in C (the latter is not appropriate for my situation now). All I want to do is run a...
4
by: rh0dium | last post by:
Hi all, I have a problem with putting a job in the background. Here is my (ugly) script which I am having problems getting to background. There are threads about doing python script.py & ...
41
by: km | last post by:
Hi all, Is there any PEP to introduce true threading features into python's next version as in java? i mean without having GIL. when compared to other languages, python is fun to code but i feel...
6
by: Graham Weldon | last post by:
Has anyone got any information or links for some tutorials on threading with PHP? I was looking at running a socket listener, and launch off new threads, and co-ordinate as requests come in. ...
10
by: qwertycat | last post by:
I'm new to multi-process programming, should one avoid forking children from children of a parent? I'd like to spawn 10 children from the parent and each of those children spawns another 5...
2
by: Gilles Ganault | last post by:
Hello I'd like to rewrite the following Perl script in Python: http://www.voip-info.org/wiki/view/Asterisk+NetCID It seems like the following doesn't actually fork, so Asterisk is stuck...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.