[python-win32] zmq under win32service
Mark Hammond
skippy.hammond at gmail.com
Mon Mar 7 21:36:56 EST 2022
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-service <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