Esempio n. 1
0
    def sendRemoteCommEvent(self, type, data):
        """ Send an event that will be received by event listener
        subprocesses subscribing to the RemoteCommunicationEvent.

        @param  string  type  String for the "type" key in the event header
        @param  string  data  Data for the event body
        @return boolean       Always return True unless error
        """
        if isinstance(type, unicode):
            type = type.encode('utf-8')
        if isinstance(data, unicode):
            data = data.encode('utf-8')

        notify(RemoteCommunicationEvent(type, data))

        return True
Esempio n. 2
0
 def test_remote_comm_event(self):
     from supervisor.events import RemoteCommunicationEvent
     event = RemoteCommunicationEvent('foo', 'bar')
     headers, payload = self._deserialize(str(event))
     self.assertEqual(headers['type'], 'foo', headers)
     self.assertEqual(payload, 'bar')
Esempio n. 3
0
 def test_RemoteCommunicationEvent_attributes(self):
     from supervisor.events import RemoteCommunicationEvent
     inst = RemoteCommunicationEvent(1, 2)
     self.assertEqual(inst.type, 1)
     self.assertEqual(inst.data, 2)
Esempio n. 4
0
 def test_remote_comm_event(self):
     from supervisor.events import RemoteCommunicationEvent
     event = RemoteCommunicationEvent('foo', 'bar')
     headers, payload = self._deserialize(event.payload())
     self.assertEqual(headers['type'], 'foo', headers)
     self.assertEqual(payload, 'bar')