Skip to content

Commit c315a15

Browse files
committed
fixes #128: module 'zmq.asyncio' has no attribute 'PUB'
fixes #126: zermoq plugin config validation wants both bind and connect to be set
1 parent 10b6cec commit c315a15

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33

44
## Unreleased
5+
### Fixed
6+
- zmq.asyncio has no attribute `PUB` (#128)
7+
- zmq plugin configuration collision between bind and connect (#126)
58

69

710
## 1.4.2

CHANGELOG.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Unreleased:
22
added: []
3-
fixed: []
3+
fixed:
4+
- 'zmq.asyncio has no attribute `PUB` (#128)'
5+
- 'zmq plugin configuration collision between bind and connect (#126)'
46
changed: []
57
deprecated: []
68
removed: []

src/vaping/plugins/zeromq.py

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
try:
2+
from zmq import PUB
23
import zmq.asyncio as zmq
34
except ImportError:
45
zmq = None
@@ -10,8 +11,8 @@
1011

1112

1213
class ZeroMQSchema(vaping.plugins.PluginConfigSchema):
13-
bind = confu.schema.Str()
14-
connect = confu.schema.Str()
14+
bind = confu.schema.Str(default="")
15+
connect = confu.schema.Str(default="")
1516

1617

1718
@vaping.plugin.register("zeromq")
@@ -41,22 +42,20 @@ def init(self):
4142
self.ctx = zmq.Context()
4243

4344
# sanity check config
44-
if "bind" in self.config:
45-
if "connect" in self.config:
45+
if self.config.get("bind"):
46+
if self.config.get("connect"):
4647
msg = "bind and connect are mutually exclusive"
4748
self.log.critical(msg)
4849
raise ValueError(msg)
49-
50-
elif "connect" not in self.config:
51-
msg = "missing bind or connect"
50+
elif not self.config.get("connect"):
5251
self.log.critical(msg)
5352
raise ValueError(msg)
5453

5554
def on_start(self):
56-
self.sock = self.ctx.socket(zmq.PUB)
57-
if "bind" in self.config:
55+
self.sock = self.ctx.socket(PUB)
56+
if self.config.get("bind"):
5857
self.sock.bind(self.config["bind"])
59-
elif "connect" in self.config:
58+
elif self.config.get("connect"):
6059
self.sock.connect(self.config["connect"])
6160

6261
def on_stop(self):

0 commit comments

Comments
 (0)