momc...@bojinov.info wrote:

server:

import zmq, json

context = zmq.Context()

socket = context.socket(zmq.REP)

socket.bind('ipc://cache/mm')

while True:

               message = socket.recv_json()

               print(message)

socket.send_json(json.dumps({"data" : "BLA BLA"}))

Once I start the service though I can’t send/receive content

Both service and cmd/client run under the same account (not SYSTEM)

Where is the service code?


I was wondering if I can even use while True without the spawning a separate thread for it ?

No.  Just like a Windows GUI app, a Windows service has a main message loop that has to remain in control, so it can receive and dispatch messages from the service manager.  The system sends "are you awake?" messages periodically to make sure you're still alive.  If you aren't getting back to the main loop, then you will be terminated.

So, if you're using the sample you mentioned, the service "def main(self):" will need to launch a thread to do your listening. You will also need to have your thread check the "stop_request" flag, so you can cleanly exit when the service is terminated.

--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

_______________________________________________
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32

Reply via email to