How to use the zmq.eventloop.ioloop function in zmq

To help you get started, we’ve selected a few zmq examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github geocam / geocamUtilWeb / geocamUtil / zmqUtil / testPublisher.py View on Github external
def stdinHandler(publisher):
    line = sys.stdin.readline()
    if not line:
        # EOF... end program
        ioloop.IOLoop.instance().stop()
        return
    line = line[:-1]
    topic, body = line.split(':', 1)
    logging.debug('publishing: %s:%s', topic, body)
    publisher.sendRaw(topic, body)
github domogik / domoweb / Domoweb.py View on Github external
#!/usr/bin/env python

import sys
if sys.version_info < (2, 6):
    print "Sorry, requires Python 2.6 or 2.7."
    sys.exit(1)

# MQ
import os
from zmq.eventloop import ioloop
ioloop.install()
import domoweb
from domoweb.handlers import MainHandler, ConfigurationHandler, WSHandler, NoCacheStaticFileHandler, MQHandler, UploadHandler,MultiStaticFileHandler, LoginHandler
from domoweb.loaders import packLoader, mqDataLoader
from domoweb.processinfo import ProcessInfo
from domogikmq.pubsub.publisher import MQPub
import zmq
import threading
import signal


from domoweb import ui_methods

#import tornado.ioloop
import tornado.web
import tornado.httpserver
from tornado.options import options
github ipython / ipython / examples / zmqontroller / controller.py View on Github external
def setup():
    """setup a basic controller and open client,registrar, and logging ports. Start the Queue and the heartbeat"""
    ctx = zmq.Context()
    loop = ioloop.IOLoop.instance()
    
    # port config
    # config={}
    execfile('config.py', globals())
    iface = config['interface']
    logport = config['logport']
    rport = config['regport']
    cport = config['clientport']
    cqport = config['cqueueport']
    eqport = config['equeueport']
    ctport = config['ctaskport']
    etport = config['etaskport']
    ccport = config['ccontrolport']
    ecport = config['econtrolport']
    hport = config['heartport']
    nport = config['notifierport']
github ipython / ipyparallel / ipyparallel / controller / sqlitedb.py View on Github external
from IPython.core.application import BaseIPythonApplication
            if BaseIPythonApplication.initialized():
                app = BaseIPythonApplication.instance()
                if app.profile_dir is not None:
                    self.location = app.profile_dir.location
                else:
                    self.location = u'.'
            else:
                self.location = u'.'
        self._init_db()

        # register db commit as 2s periodic callback
        # to prevent clogging pipes
        # assumes we are being run in a zmq ioloop app
        loop = ioloop.IOLoop.instance()
        pc = ioloop.PeriodicCallback(self._db.commit, 2000, loop)
        pc.start()
github ipython / ipython / IPython / frontend / html / notebook / heartbeat.py View on Github external
self.stream.send(b'ping')
                    # flush stream to force immediate socket send
                    self.stream.flush()
                else:
                    try:
                        callback()
                    except:
                        pass
                    finally:
                        self.stop()

            def beat_received(msg):
                self._kernel_alive = True

            self.stream.on_recv(beat_received)
            self._hb_periodic_callback = ioloop.PeriodicCallback(
                ping_or_dead, self.time_to_dead*1000, self.loop
            )
            self.loop.add_timeout(time.time()+self.first_beat, self._really_start_hb)
            self._beating= True
github albertz / pydbattach / alternatives / ipython_remote_shell.py View on Github external
def ipython_thread():
    kernel.start()
    try:
      ioloop.IOLoop.instance().start()
    except KeyboardInterrupt:
      pass
github mattvonrocketstein / smash / smashlib / ipy3x / kernel / zmq / zmqshell.py View on Github external
def _exit_now_changed(self, name, old, new):
        """stop eventloop when exit_now fires"""
        if new:
            loop = ioloop.IOLoop.instance()
            loop.add_timeout(time.time() + 0.1, loop.stop)
github zeromq / pyzmq / examples / web / backend_stream.py View on Github external
observe the timeout behavior.
 """

#-----------------------------------------------------------------------------
#  Copyright (c) 2012 Brian Granger, Min Ragan-Kelley
#
#  Distributed under the terms of the New BSD License.  The full license is in
#  the file COPYING.BSD, distributed as part of this software.
#-----------------------------------------------------------------------------

import logging
logging.basicConfig(level=logging.DEBUG)
import time

from zmq.eventloop import ioloop
ioloop.install()
from tornado import web

from zmq.web import ZMQApplication, ZMQStreamingHTTPRequest

def flush_callback():
    logging.info('Done flushing zmq buffers')

class FooHandler(web.RequestHandler):

    @web.asynchronous
    def get(self):
        self.set_header('Handler', 'FooHandler')
        # Each write/flush pair is send back to the frontend/browser immediately.
        self.write('pow\n')
        self.flush(callback=flush_callback)
        self.bam_count = 10
github miphreal / python-logdog / arch / dog / app.py View on Github external
def main(config):
    zmq.eventloop.ioloop.install()
    Application(config=config).run()
github geocam / geocamUtilWeb / geocamUtil / zmqUtil / zmqCentral.py View on Github external
parser.add_option('-c', '--consoleLog',
                      default='zmqCentral-console-%s.txt',
                      help='Log file for debugging zmqCentral [%default]')
    parser.add_option('-f', '--foreground',
                      action='store_true', default=False,
                      help='Do not daemonize zmqCentral on startup')
    #parser.add_option('--highWaterMark',
    #                  default=10000, type='int',
    #                  help='High-water mark for publish socket (see 0MQ docs) [%default]')
    opts, args = parser.parse_args()
    if args:
        parser.error('expected no args')
    zc = ZmqCentral(opts)
    zc.start()
    atexit.register(zc.shutdown)
    ioloop.IOLoop.instance().start()