What's the best way to communicate between processes?

G

Guest

Here's my situation:

I'm writing a simple reminder bot which will IM me based on input from
a web server. Right now, I have a simple AIM bot written using twisted
2 words. It logs into AIM and can send/receive messages. There's part
1.

I have a django server running under mod_python through apache, which
is my web server. Part 2.

How do I get part 2 to talk to part 1?? Ideally I'd like to fire off a
(signal/message/data) from mod_python to a separate process running the
twisted AIM bot, so that the mod_python thread(s) can just forget about
the whole thing and let someone else deal with talking with AIM.

I can't really just include the twisted AIM bot from django, because
mod_python (as I understand it) runs different requests on different
threads, and I don't want to spawn a bot and log into IM each request.
I can't run the whole thing through twisted, either.

I'm thinking about coding some sort of 'local notify server' in twisted
(basically just listening to a socket and then passing the information
to the IM bot), then connecting to it via a python socket in django and
passing some serialized/pickled data. I worry about two requests
connecting to the 'notify server' at once, though, because i *cannot*
hang my web server.

Thoughts? Is there a better solution? Is there a simpler way to do this
(a way with built-in serialization?)

Thanks for any help.
 
L

Lawrence D'Oliveiro

In message <[email protected]>,
I'm thinking about coding some sort of 'local notify server' in twisted
(basically just listening to a socket and then passing the information
to the IM bot), then connecting to it via a python socket in django and
passing some serialized/pickled data.

That sounds like the right sort of thing. I've done this sort of thing
myself, though I've been careful not to use any language-specific
communication formats.
I worry about two requests
connecting to the 'notify server' at once, though, because i *cannot*
hang my web server.

Your Web server won't hang. The particular Web server thread/process waiting
for the request to be serviced will be held up, and so of course will the
particular user sitting in front of the browser waiting for a response from
that thread/process, but nobody else will notice anything.
 
G

grahamd

I'm thinking about coding some sort of 'local notify server' in twisted
(basically just listening to a socket and then passing the information
to the IM bot), then connecting to it via a python socket in django and
passing some serialized/pickled data.

Use the XML-RPC server gateway from Twisted on the server side. In
the Django web pages then use xmlrpclib module to initiate XML-RPC
requests to the server.

Graham
 
G

Guest

In general, are sockets used for intra-machine communication less
likely to fail/hang than, say, trying to connect across countries? I
would think so, right?

How do web servers handle connections to SQL databases? Do they spawn a
thread? Or is it all inline? Seems like that's the type of
behaviour/connection I'd like to model.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top