~ubuntu-branches/ubuntu/precise/pyzmq/precise

« back to all changes in this revision

Viewing changes to zmq/devices/basedevice.py

  • Committer: Package Import Robot
  • Author(s): Debian Python Modules Team
  • Date: 2011-09-23 00:16:39 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: package-import@ubuntu.com-20110923001639-girjqodpb7uv17yu
Tags: 2.1.9-1
* New upstream version
  - should build on kFreeBSD without patches (Closes: #637777).
* Build-depend on zeromq 2.1.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
 
57
57
    For instance::
58
58
 
59
 
        dev = Device(zmq.QUEUE, zmq.XREQ, zmq.XREP)
 
59
        dev = Device(zmq.QUEUE, zmq.DEALER, zmq.ROUTER)
60
60
 
61
61
    Similar to zmq.device, but socket types instead of sockets themselves are
62
62
    passed, and the sockets are created in the work thread, to avoid issues
90
90
        sets whether the thread should be run as a daemon
91
91
        Default is true, because if it is false, the thread will not
92
92
        exit unless it is killed
 
93
    context_factory : callable (class attribute)
 
94
        Function for creating the Context. This will be Context.intance
 
95
        in ThreadDevices, and Context in ProcessDevices.  The only reason
 
96
        it is not instance() in ProcessDevices is that there may be a stale
 
97
        Context instance already initialized, and the forked environment
 
98
        should *never* try to use it.
93
99
    """
 
100
    
 
101
    context_factory = Context.instance
94
102
 
95
103
    def __init__(self, device_type, in_type, out_type):
96
104
        self.device_type = device_type
148
156
        self._out_sockopts.append((opt, value))
149
157
    
150
158
    def _setup_sockets(self):
151
 
        ctx = Context()
 
159
        ctx = self.context_factory()
 
160
        
152
161
        self._context = ctx
153
162
        
154
163
        # create the sockets
230
239
    See Device for details.
231
240
    """
232
241
    _launch_class=Process
 
242
    context_factory = Context
233
243
 
234
244
 
235
245
__all__ = [ 'Device', 'ThreadDevice']