Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, emit_addr=EMIT_ADDR, reg_addr=REG_ADDR,
path_prefix=None):
"""
Initialize the events server.
"""
TxZmqClientComponent.__init__(self, path_prefix=path_prefix)
EventsClient.__init__(self, emit_addr, reg_addr)
# connect SUB first, otherwise we might miss some event sent from this
# same client
self._sub = self._zmq_connect(txzmq.ZmqSubConnection, reg_addr)
self._sub.gotMessage = self._gotMessage
self._push = self._zmq_connect(txzmq.ZmqPushConnection, emit_addr)
def __init__(self):
self.subscribers = []
self.zf2 = ZmqFactory()
self.e2 = ZmqEndpoint('connect', 'tcp://127.0.0.1:5555')
self.s2 = ZmqSubConnection(self.zf2, self.e2)
self.s2.subscribe("")
self.s2.gotMessage = self._on_message
self.proxy = Proxy('http://127.0.0.1:7080')
self.tid_map = {}
self.subscribers = []
self.reactor = reactor
def __init__(self, hub, config):
self.config = config
self.validate_config(self.config)
self.strict = asbool(self.config.get('zmq_strict', False))
self.subscriber_factories = {}
self.context = zmq.Context(1)
# Configure txZMQ to use our highwatermark and keepalive if we have 'em
self.connection_cls = txzmq.ZmqSubConnection
self.connection_cls.highWaterMark = \
config.get('high_water_mark', 0)
self.connection_cls.tcpKeepalive = \
config.get('zmq_tcp_keepalive', 0)
self.connection_cls.tcpKeepaliveCount = \
config.get('zmq_tcp_keepalive_cnt', 0)
self.connection_cls.tcpKeepaliveIdle = \
config.get('zmq_tcp_keepalive_idle', 0)
self.connection_cls.tcpKeepaliveInterval = \
config.get('zmq_tcp_keepalive_intvl', 0)
self.connection_cls.reconnectInterval = \
config.get('zmq_reconnect_ivl', 100)
self.connection_cls.reconnectIntervalMax = \
config.get('zmq_reconnect_ivl_max', 100)
# Set up the publishing socket
def __init__(self, reactor, screen_ui, audio_player, first_block_hash):
f = ZmqFactory()
f.reactor = reactor
e = ZmqEndpoint("connect", "tcp://127.0.0.1:28332")
s = ZmqSubConnection(f, e)
s.subscribe("hashblock".encode("utf-8"))
s.messageReceived = self.listener
self.screen_ui = screen_ui
self.new_block_queue = []
self.queue_running = False
self.audio_player = audio_player
new_block = NewBlock(self, first_block_hash, self.screen_ui,
audio_player)
self.new_block_queue.append(new_block)
self._try_next()
from Queue import Empty # Python 2
if sys.version.startswith("3"):
unicode = str
_zmq_factory = ZmqFactory()
def cleanup(proto):
if hasattr(proto, '_session') and proto._session is not None:
if proto._session.is_attached():
return proto._session.leave()
elif proto._session.is_connected():
return proto._session.disconnect()
class ZmqProxyConnection(ZmqSubConnection):
def __init__(self, endpoint, wamp_session, prefix):
self._endpoint = endpoint
self._wamp = wamp_session
self._prefix = prefix
ZmqSubConnection.__init__(self, _zmq_factory, ZmqEndpoint('connect', endpoint.encode("utf-8")))
self.subscribe(b"")
def gotMessage(self, message, header=""):
# log.msg("[MachineConnection] {} {}".format(header, message))
self._wamp.publish(self._prefix, [str(header), json.loads(message.decode("utf-8"))])
def build_bridge_class(client):
_key = client.session.key.decode("utf-8")
class JupyterClientWampBridge(ApplicationSession):
iopub_deferred = None
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from txzmq import ZmqFactory, ZmqEndpoint, ZmqEndpointType, ZmqSubConnection
import logging
import json
from util import Identity
class ZmqSubscriber(ZmqSubConnection):
def __init__(self, remote_host, port, zmq_factory, data_manager=None):
self.data_manager = data_manager
self.remote_host = remote_host
self.generation_signal_listeners = []
endpoint = ZmqEndpoint(ZmqEndpointType.connect, "tcp://%s:%d" % (remote_host, port))
ZmqSubConnection.__init__(self, zmq_factory, endpoint)
def shutdown(self):
self.unsubscribe("GENSIG")
ZmqSubConnection.shutdown(self)
def subscribe_generation_signal(self, callback, *args):
def __init__(self, zmq_endpoint, rpc_endpoint):
self.subscribers = []
print zmq_endpoint
self.zf2 = ZmqFactory()
self.e2 = ZmqEndpoint('connect', zmq_endpoint)
self.s2 = ZmqSubConnection(self.zf2, self.e2)
self.s2.subscribe("")
self.s2.gotMessage = self._on_message
self.proxy = Proxy(rpc_endpoint)
self.tid_map = {}
self.subscribers = []
self.reactor = reactor
logger.info('Started')
sockjs_options = {
'websocket': True,
'cookie_needed': False,
'heartbeat': 25,
'timeout': 5,
'streaming_limit': 128 * 1024,
'encoding': 'cp1252', # Latin1
'sockjs_url': 'https://d1fxtkz8shb9d2.cloudfront.net/sockjs-0.3.js'
}
zf = ZmqFactory()
endpoint = '%s://localhost:%d' % (settings.FORWARDER_PUB_TRANSPORT,
settings.FORWARDER_PUB_PORT)
e = ZmqEndpoint("connect", endpoint)
subscription = ZmqSubConnection(zf, e)
# Subscripción a todos los mensajes
subscription.subscribe("")
class SockJSProtocol(protocol.Protocol):
DIRECT_FORWARD_MESSAGE_TYPES = ('echo', )
instances = []
def __init__(self, *largs, **kwargs):
print "SockJS"
#protocol.Protocol.__init__(*largs, **kwargs)
SockJSProtocol.instances.append(self)
def dataReceived(self, data_string):
try: