def __init__(self, message_queue, socket_name='EventService_EventRanges', context='local', **kwds): """ Initialize yampl server socket. :param message_queue: a queue to transfer messages between current instance and ESProcess. :param socket_name: name of the socket between current process and payload. :param context: name of the context between current process and payload, default is 'local'. :param **kwds: other parameters. :raises MessageFailure: when failed to setup message socket. """ threading.Thread.__init__(self, **kwds) self.setName("MessageThread") self.__message_queue = message_queue self._stop = threading.Event() logger.info('try to import yampl') try: import yampl except Exception as e: raise MessageFailure("Failed to import yampl: %s" % e) logger.info('finished to import yampl') logger.info('start to setup yampl server socket.') try: self.__message_server = yampl.ServerSocket(socket_name, context) except Exception as e: raise MessageFailure("Failed to setup yampl server socket: %s %s" % (e, traceback.print_exc())) logger.info('finished to setup yampl server socket.')
def __init__(self, socketname='EventService_EventRanges', context='local'): # create server socket for yampl try: self.socket = yampl.ServerSocket(socketname, context) except Exception: logger.exception('failed to create yampl server socket') raise
def __init__(self, messageQ, socketname, context, **kwds): threading.Thread.__init__(self, **kwds) self.__log = Logger.Logger(filename='EventServiceManager.log') self.__messageQ = messageQ self._stop = threading.Event() try: self.__messageSrv = yampl.ServerSocket(socketname, context) except: self.__log.debug("Exception: failed to start yampl server socket: %s" % traceback.format_exc())
def __init__(self, messageQ, socketname, context='local', logger=None, **kwds): threading.Thread.__init__(self, **kwds) if logger: self.logger = logger else: self.logger = logging.getLogger(self.__class__.__name__) self.messageQ = messageQ self.num_messages_required = 0 self._stop = threading.Event() try: self.__messageSrv = yampl.ServerSocket(socketname, context) except: self.logger.debug("Exception: failed to start yampl server socket: %s" % traceback.format_exc())
def __init__(self, name='PilotYamplServer', socketname='EventService_EventRanges', context='local'): """ Constructor, setting initial variables """ self.srv = None self.receivedMessage = "" self.sendMessage = "" # Default signals signal.signal(signal.SIGINT, signal.SIG_DFL) # Create the server socket try: self.srv = yampl.ServerSocket(socketname, context) except Exception, e: tolog("!!WARNING!!2222!! Could not create Yampl server socket")
#!/usr/bin/python import yampl import signal signal.signal(signal.SIGINT, signal.SIG_DFL) s = yampl.ServerSocket("service", "local_pipe") size, buf = s.recv() s.send("hello world!") print(buf)
def __init__(self, messageQ, socketname, context, **kwds): threading.Thread.__init__(self, **kwds) self.__messageQ = messageQ self._stop = threading.Event() self.__messageSrv = yampl.ServerSocket(socketname, context)