Example #1
0
def parent():
    print "parent: okay, parent here."
    sleep(1)
    print "parent: I'm so excited, about to become a parent"
    sleep(1)
    fork_child(end_the_app_when_my_parent_dies)
    sleep(1)
    print "parent: and, there he goes.  I'm so proud"
    sleep(4)
    print "parent: okay, I'm outta here"
Example #2
0
def parent():
    print "parent: okay, parent here."
    sleep(1)
    print "parent: I'm so excited, about to become a parent"
    sleep(1)
    fork_child(end_the_app_when_my_parent_dies)
    sleep(1)
    print "parent: and, there he goes.  I'm so proud"
    sleep(4)
    print "parent: okay, I'm outta here"
def main():
    start = time.time()

    for i in xrange(NUM_ITEMS):
        q.put('item %d' % i)
    for i in xrange(NUM_WORKERS):
        q.put(shutdown)

    for i in xrange(NUM_WORKERS):
        diesel.fork_child(worker)
    for i in xrange(NUM_WORKERS):
        dones.get()

    print 'all workers done in %.2f secs' % (time.time() - start)
    diesel.quickstop()
Example #4
0
    def _handle_all_inbound_and_outbound_traffic(self):
        assert self.zmq_socket
        diesel.fork_child(self._receive_incoming_messages)
        queues = [self.incoming, self.outgoing]
        while True:
            (queue, msg) = diesel.first(waits=queues)

            if queue is self.incoming:
                if msg.remote_identity not in self.clients:
                    self._register_client(msg)
                self.clients[msg.remote_identity].incoming.put(msg)

            elif queue is self.outgoing:
                self.zmq_socket.send(msg.zmq_return, zmq.SNDMORE)
                self.zmq_socket.send(msg.data)
Example #5
0
def main():
    start = time.time()

    for i in xrange(NUM_ITEMS):
        q.put('item %d' % i)
    for i in xrange(NUM_WORKERS):
        q.put(shutdown)

    for i in xrange(NUM_WORKERS):
        diesel.fork_child(worker)
    for i in xrange(NUM_WORKERS):
        dones.get()

    print 'all workers done in %.2f secs' % (time.time() - start)
    diesel.quickstop()
Example #6
0
    def _handle_all_inbound_and_outbound_traffic(self):
        assert self.zmq_socket
        diesel.fork_child(self._receive_incoming_messages)
        queues = [self.incoming, self.outgoing]
        while True:
            (queue, msg) = diesel.first(waits=queues)

            if queue is self.incoming:
                if msg.remote_identity not in self.clients:
                    self._register_client(msg)
                self.clients[msg.remote_identity].incoming.put(msg)

            elif queue is self.outgoing:
                self.zmq_socket.send(msg.zmq_return, zmq.SNDMORE)
                self.zmq_socket.send(msg.data)
Example #7
0
 def _register_client(self, msg):
     remote = RemoteClient.from_message(msg)
     self.clients[msg.identity] = remote
     self.register_client(remote, msg)
     diesel.fork_child(self._handle_client_requests_and_responses, remote)
Example #8
0
 def _register_client(self, msg):
     remote = RemoteClient.from_message(msg)
     self.clients[msg.remote_identity] = remote
     self.register_client(remote, msg)
     diesel.fork_child(self._handle_client_requests_and_responses, remote)
Example #9
0
 def parent():
     fork_child(dependent_child)
     sleep(0.1)
     a = b # undef
Example #10
0
 def parent():
     fork_child(dependent_child, got_exception)
     sleep(0.1)
     a = b # undef
Example #11
0
 def parent():
     fork_child(dependent_child, got_exception)
     sleep(0.1)
     a = b  # undef
Example #12
0
def protective_parent(child, children):
    child = fork_child(child)
    child.keep_alive = True
    children[0] = child
    sleep(2)
Example #13
0
 def parent():
     fork_child(dependent_child)
     sleep(0.1)
     a = b  # undef
Example #14
0
def protective_parent(child, children):
    child = fork_child(child)
    child.keep_alive = True
    children[0] = child
    sleep(2)