Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View minrk's full-sized avatar

Min RK minrk

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@minrk
minrk / zmq_cli.py
Created January 17, 2011 08:34 — forked from amacleod/zmq_cli.py
#!/usr/bin/python
"""
zmq_cli - 0MQ Server interruptability test case, client module.
"""
import zmq
# override ioloop.IOLoop with zmq's IOLoop
import sys
import tornado.ioloop
from zmq.eventloop import ioloop
tornado.ioloop.IOLoop = ioloop.IOLoop
import trombi
loop = ioloop.IOLoop.instance()
# check that tornado's ioloop instance is actually zmq's
@minrk
minrk / ZeroMQ-XPUB.py
Created April 3, 2012 23:24 — forked from m0sa/ZeroMQ-XPUB.py
Example of the ZeroMQ XPUB socket, that shows how the producer can be controlled by the number of subscribers
import thread
import time
import zmq
# global zmg context
context = zmq.Context()
endpoint = "tcp://*:8888"
# the subscriber thread function
def subscriber(name, address, cnt, subscriptions):
"""
A test forking server
To start a single kernel by forking, do::
python -i testfork.py
The kernel object will be in the ``a`` variable. When you close the
python session, the forked kernel will be killed.
"""
from IPython.frontend.qt.console.qtconsoleapp import IPythonQtConsoleApp
a = IPythonQtConsoleApp()
a.initialize()
# load the sympyprinting extension in the kernel before starting
a.kernel_manager.shell_channel.execute("%load_ext sympyprinting", silent=True)
a.start()
import json, time, threading
import zmq
from zmq.eventloop import ioloop, zmqstream
class Logger( threading.Thread ):
def __init__( self, *args, **kwargs ):
threading.Thread.__init__( self )
self.rtrSocket = None
self.stream = None
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import os
from IPython.frontend.qt.console.rich_ipython_widget import RichIPythonWidget
from IPython.frontend.qt.kernelmanager import QtKernelManager
from IPython.frontend.qt.inprocess_kernelmanager import QtInProcessKernelManager
from IPython.kernel.zmq.ipkernel import Kernel
from IPython.kernel.inprocess.ipkernel import InProcessKernel
from IPython.lib import guisupport
from IPython.parallel import Client
from IPython.parallel import interactive
import time
import random
@interactive
def work(i):
import time
import random
sleeptime = 1 + random.random() * 2