473,563 Members | 2,856 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2442

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
6449
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. "somethread.interrupt()" will wake somethread up when it's in sleeping/waiting state. Is there any way of doing this with python's thread? I suppose thread...
0
1747
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 the Python process. obviously, I needed some way to receive and processed SMTP. smtpd.py works OK if you are willing to use single threaded one at...
0
2258
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 $!; $listen->autoflush(1);
4
1256
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 function in a new thread, it's a simple task, no interaction with other threads etc. so I don't have to worry about deadlock, starvation and so on. ...
4
3882
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 & and others
41
2321
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 its is lacking behind in threading regards, KM
6
10148
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. Cheers, Graham
10
2166
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 children which process chunks of data (200 rows) with heavy usage of CPU and regexp
2
1745
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 until the script ends: ===========
0
7583
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7888
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2082
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1200
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.