2

So we are writing a chat server with a web server and web client using Python twisted.

The chat server is on main process and spawn a new sub process to run the web server and client. The main process (chat server) is required to send/receive events and data to/from sub process (web server n client) to auth connected users and admin websites etc.

This is how, we are spawning sub process for web server/client: reactor.spawnProcess(ProcessProtocolClass_instance, sys.executable*(python exe file), [sys.executable(python exe file)*, 'WebServer.py (full path of web sever client python file)'])

We are not new to python and twisted. Can some one help us to figure out the best way to communicate between main and sub process, spawned with python twisted and running python file on sub process. To send the data time to time.

Thanks.

  • Can you be more specific? – Jean-Paul Calderone Sep 19 '14 at 10:50
  • Thanks for reply bro. I love to be more specific, I guess you want more details for what kind of communication. – Chuck James Sep 19 '14 at 15:11
  • I guess you want more details for what kind of communication. So, we have server running/coded in twested/autobahn and it's serving to js client for chat (ws conn). And it has a web client (to request auth http call from django server (a separate box) and server (to serve http for admin site). Chat server is on main process, it creates(spawn) a new sub process running web clients and admin server. My question is How to communicate between chat server (running on main process) to web client and admin server (running on sub process) on linux/Mac. – Chuck James Sep 19 '14 at 15:28
  • You found `reactor.spawnProcess` and you pointed out (correctly) that it accepts a `ProcessProtocol` (or subclass) instance. The general answer to the question is "The `ProcessProtocol` instance lets you communicate with the child". – Jean-Paul Calderone Sep 19 '14 at 16:50
  • I got that part, but how to communicate from python file (running web client n server) running on sub process to main python file running on main process (Chat server). --------------------------------------- Chat server (main process) ---> web server (sub process) Chat server (main process) <--- web server (sub process) ---------------------------------------------------------- HOW? I didn't find any example nothing is out there... to answer my question. – Chuck James Sep 19 '14 at 18:47
  • Did you read the documentation for `spawnProcess`? https://twistedmatrix.com/documents/current/core/howto/process.html – Jean-Paul Calderone Sep 20 '14 at 19:17
  • Yes I did, long back but still not clear. They have talked about processProtocol side of code but not the other side. There are two end points of every communication. They talked about only one, or I didn't understand the other if you did then please explain. – Chuck James Sep 23 '14 at 21:57
  • Ah, I see. I think you're asking about `twisted.internet.stdio` (if the child process is using Twisted). – Jean-Paul Calderone Sep 24 '14 at 12:24

0 Answers0