[python-win32] zmq under win32service

momchil at bojinov.info momchil at bojinov.info
Tue Mar 8 01:50:01 EST 2022


Hi,

Thank you for responding

I do have a logging class I use in my framework. I get a log entry right before the loop and nothing from inside
Wherever I put 'print' in the sample consider 'log.info'
Zmq is not raising much anyway and making this difficult. 

Now that I have not consumed rakia in 8 hours and having had a good night sleep - I switched the IPC with a TCP socket and it worked OK

My question now is (realizing this is the wrong forum to ask) should this work with IPC ?
One process being a user one and the other one being a service - both running under the same user

Momchil

-----Original Message-----
From: Mark Hammond <skippy.hammond at gmail.com> 
Sent: Tuesday, March 8, 2022 4:37 AM
To: momchil at bojinov.info; python-win32 at python.org
Subject: Re: [python-win32] zmq under win32service

I've no clear idea what might be going wrong, but:

* The `while True` should be fine - it obviously has limitations, but will work in the simple case.

* You need some way of working out *what* is going wrong before you can work out *why*. It's possible the `print` statements are failing - I don't think the service framework does anything to ensure sys.stdout is valid. Most examples use `win32traceutil` to redirect sys.stdout, or you can use the event-log or anything else, but knowing exactly what is failing (ie, exactly how far it is getting) will be necessary to understand.

Cheers,

Mark

On 8/03/2022 9:08 am, momchil at bojinov.info wrote:
> Hello,
> 
> I m trying to serve 0mq listener under win32 service
> 
> Code works fine while in interactive session
> 
> Client:
> 
> import zmq, json
> 
> context = zmq.Context()
> 
> socket = context.socket(zmq.REQ)
> 
> socket.connect('ipc://cache/mm')
> 
> socket.send_json(json.dumps({"2" : "1"}))
> 
> message = socket.recv_json()
> 
> print(message)
> 
> 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)
> 
> I was wondering if I can even use while True without the spawning a 
> separate thread for it ?
> 
> I m using the service code from:
> 
> https://stackoverflow.com/questions/55677165/python-flask-as-windows-s
> ervice 
> <https://stackoverflow.com/questions/55677165/python-flask-as-windows-
> service>
> 
> (And the service skeleton /*win32_service.py*/)
> 
> Help appreciated
> 
> Momchil
> 
> 
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> https://mail.python.org/mailman/listinfo/python-win32





More information about the python-win32 mailing list