python - Tornado + ZMQstream raises TypeError -


i have tornado application serves bridge between back-end service , javascript client. communication backend app --zmq--> streamer --ws--> js client. code looks this:

streamer.py

import os import zmq  zmq.eventloop import ioloop zmq.eventloop.zmqstream import zmqstream zmq.utils.strtypes import cast_unicode ioloop.install()  tornado import websocket, web, ioloop ioloop = ioloop.ioloop.instance()   # store clients cl = []   def setupzmqsubscriber():        sub_sct = context.socket(zmq.sub)     sub_sct.connect(address)     sub_sct.setsockopt(zmq.subscribe, b"")      stream = zmqstream(sub_sct)      def on_data(msg):         c in cl:             c.write_message(msg)      stream.on_recv(on_data)   class mywebsocket(websocket.websockethandler):      def check_origin(self, origin):         return true      def open(self):         self.write_message(...)         if self not in cl:             cl.append(self)      def on_close(self):         if self in cl:             cl.remove(self)   if __name__ == '__main__':     streamer= web.application([         (r'/ws', mywebsocket),     ])     streamer.listen(port)     setupzmqsubscriber()     ioloop.start() 

it working on windows when tried run on linux ubuntu server i'm getting following error:

traceback (most recent call last):   file "/usr/lib/python3.5/multiprocessing/process.py", line 249, in _bootstrap     self.run()   file "/usr/lib/python3.5/multiprocessing/process.py", line 93, in run     self._target(*self._args, **self._kwargs)   file "/home/.../streamer.py", line 92, in setupzmqsubscriber()   file "/home/.../streamer.py", line 57, in setupzmqsubscriber     stream = zmqstream(sub_sct)   file "/home/.../lib/python3.5/site-packages/zmq/eventloop/zmqstream.py", line 114, in __init__     self._init_io_state()   file "/home/.../lib/python3.5/site-packages/zmq/eventloop/zmqstream.py", line 535, in _init_io_state     self.io_loop.add_handler(self.socket, self._handle_events, self._state)   file "/home/.../lib/python3.5/site-packages/tornado/ioloop.py", line 725, in add_handler     self._impl.register(fd, events | self.error) typeerror: argument must int, or have fileno() method. 

i tried other alternatives install ioloop according pyzmq docs i'm getting same error.

update

after first investigation think possible problem might multiprocessing module. i'm spawning streamer.py using multiprocessing library other scripts , raises error. however, wrote similar zmq/ws forwarder single script , when execute directly working expected. streamer.py works correctly direct execution/spawn using multiprocessing on windows fails on linux if multiprocessing used.


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -