Skip to content

Commit f58b611

Browse files
committed
Add missing context to ClientBase & ServerBase
1 parent 44e99b5 commit f58b611

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

zerorpc/core.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,19 @@
3737
from .channel import ChannelMultiplexer, BufferedChannel
3838
from .socket import SocketBase
3939
from .heartbeat import HeartBeatOnChannel
40+
from .context import Context
4041

4142

4243
class ServerBase(object):
4344

44-
def __init__(self, channel, methods=None, name=None, pool_size=None,
45-
heartbeat=5):
45+
def __init__(self, channel, methods=None, name=None, context=None,
46+
pool_size=None, heartbeat=5):
4647
self._multiplexer = ChannelMultiplexer(channel)
4748

4849
if methods is None:
4950
methods = self
5051

52+
self._context = context or Context.get_instance()
5153
self._name = name or repr(methods)
5254
self._task_pool = gevent.pool.Pool(size=pool_size)
5355
self._acceptor_task = None
@@ -164,10 +166,11 @@ def stop(self):
164166

165167
class ClientBase(object):
166168

167-
def __init__(self, channel, patterns, timeout=30, heartbeat=5,
169+
def __init__(self, channel, patterns, context=None, timeout=30, heartbeat=5,
168170
passive_heartbeat=False):
169171
self._multiplexer = ChannelMultiplexer(channel,
170172
ignore_broadcast=True)
173+
self._context = context or Context.get_instance()
171174
self._patterns = patterns
172175
self._timeout = timeout
173176
self._heartbeat_freq = heartbeat
@@ -327,7 +330,8 @@ def __init__(self, methods=None, name=None, context=None, pool_size=None,
327330
if methods is None:
328331
methods = self
329332
methods = ServerBase._zerorpc_filter_methods(Server, self, methods)
330-
ServerBase.__init__(self, self._events, methods, name, pool_size, heartbeat)
333+
ServerBase.__init__(self, self._events, methods, name, context,
334+
pool_size, heartbeat)
331335

332336
def close(self):
333337
ServerBase.close(self)
@@ -340,8 +344,8 @@ class Client(SocketBase, ClientBase):
340344
def __init__(self, context=None, timeout=30, heartbeat=5,
341345
passive_heartbeat=False):
342346
SocketBase.__init__(self, zmq.XREQ, context=context)
343-
ClientBase.__init__(self, self._events, Client.patterns, timeout,
344-
heartbeat, passive_heartbeat)
347+
ClientBase.__init__(self, self._events, Client.patterns, context,
348+
timeout, heartbeat, passive_heartbeat)
345349

346350
def close(self):
347351
ClientBase.close(self)

0 commit comments

Comments
 (0)