Skip to content

Commit fcc410a

Browse files
committed
Fix ZeroMQSocketListener and ZeroMQSocketHandler examples
1 parent 07f1658 commit fcc410a

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

Doc/howto/logging-cookbook.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,7 +1259,7 @@ socket is created separately and passed to the handler (as its 'queue')::
12591259
class ZeroMQSocketHandler(QueueHandler):
12601260
def enqueue(self, record):
12611261
data = json.dumps(record.__dict__)
1262-
self.queue.send(data)
1262+
self.queue.send_string(data)
12631263

12641264
handler = ZeroMQSocketHandler(sock)
12651265

@@ -1272,11 +1272,11 @@ data needed by the handler to create the socket::
12721272
self.ctx = ctx or zmq.Context()
12731273
socket = zmq.Socket(self.ctx, socktype)
12741274
socket.bind(uri)
1275-
QueueHandler.__init__(self, socket)
1275+
super().__init__(socket)
12761276

12771277
def enqueue(self, record):
12781278
data = json.dumps(record.__dict__)
1279-
self.queue.send(data)
1279+
self.queue.send_string(data)
12801280

12811281
def close(self):
12821282
self.queue.close()
@@ -1292,8 +1292,9 @@ of queues, for example a ZeroMQ 'subscribe' socket. Here's an example::
12921292
def __init__(self, uri, *handlers, **kwargs):
12931293
self.ctx = kwargs.get('ctx') or zmq.Context()
12941294
socket = zmq.Socket(self.ctx, zmq.SUB)
1295-
socket.setsockopt(zmq.SUBSCRIBE, '') # subscribe to everything
1295+
socket.setsockopt_string(zmq.SUBSCRIBE, '') # subscribe to everything
12961296
socket.connect(uri)
1297+
super().__init__(socket, *handlers, **kwargs)
12971298

12981299
def dequeue(self):
12991300
msg = self.queue.recv()

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1559,6 +1559,7 @@ Martin Teichmann
15591559
Gustavo Temple
15601560
Mikhail Terekhov
15611561
Victor Terrón
1562+
Pablo Galindo
15621563
Richard M. Tew
15631564
Tobias Thelen
15641565
Christian Theune

0 commit comments

Comments
 (0)