Skip to content

Commit 571eef1

Browse files
committed
Fix pyzmq adapter
1 parent 5bc64f6 commit 571eef1

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ group :test do
1717
gem 'cztop'
1818
gem 'rbczmq'
1919
gem 'ffi-rzmq'
20+
gem 'pycall', '>= 1.2.1'
2021
end

ci/Dockerfile.base.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ RUN apt-get update \
88
python3 \
99
python3-pip \
1010
python3-setuptools \
11+
libpython3.6 \
1112
&& pip3 install wheel \
1213
&& pip3 install -r /tmp/requirements.txt \
1314
&& rm -f /tmp/requirements.txt

lib/iruby/session_adapter/pyzmq_adapter.rb

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,29 @@ def make_pub_socket(protocol, host, port)
2424
make_socket(:REP, protocol, host, port)
2525
end
2626

27+
def heartbeat_loop(sock)
28+
PyCall.sys.path.append(File.expand_path('../pyzmq', __FILE__))
29+
heartbeat = PyCall.import_module('iruby.heartbeat')
30+
@heartbeat_thread = heartbeat.Heartbeat.new(sock)
31+
@heartbeat_thread.start
32+
end
2733

2834
private
2935

3036
def socket_type(type_symbol)
3137
case type_symbol
32-
when :ROUTER, :PUB
33-
zmq.__getattr__(type_symbol)
38+
when :ROUTER, :PUB, :REP
39+
zmq[type_symbol]
3440
else
35-
if zmq.__hasattr__(type_symbol)
36-
raise ArgumentError, "Unsupported ZMQ socket type: #{type_symbol}"
37-
else
38-
raise ArgumentError, "Unknown ZMQ socket type: #{type_symbol}"
39-
end
41+
raise ArgumentError, "Unknown ZMQ socket type: #{type_symbol}"
4042
end
4143
end
4244

4345
def make_socket(type_symbol, protocol, host, port)
4446
type = socket_type(type_symbol)
45-
zmq_context.socket(type)
47+
sock = zmq_context.socket(type)
4648
bind_socket(sock, protocol, host, port)
49+
sock
4750
end
4851

4952
def bind_socket(sock, protocol, host, port)
@@ -62,7 +65,7 @@ def bind_socket(sock, protocol, host, port)
6265
end
6366

6467
def zmq_context
65-
zmq.Context.instance.()
68+
zmq.Context.instance
6669
end
6770

6871
def zmq

run-test.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
set -ex
44

5-
# ADAPTERS="cztop rbczmq ffi-rzmq pyzmq"
6-
ADAPTERS="cztop rbczmq ffi-rzmq"
5+
export PYTHON=python3
6+
7+
ADAPTERS="cztop rbczmq ffi-rzmq pyzmq"
78

89
for adapter in $ADAPTERS; do
910
export IRUBY_TEST_SESSION_ADAPTER_NAME=$adapter

0 commit comments

Comments
 (0)