Exemplo n.º 1
0
class Driver():
    def __init__(self, driver_name):
        self.driver_name = driver_name
        self.listener = FifoListener('req_' + driver_name, self.def_handler)
        self.writer = FifoWriter('resp_' + driver_name)

    def def_handler(self, str):
        self.writer.write_to_stream(str.lower())

    def start(self):
        # print('[DRIVER_{}]Starting'.format(self.driver_name))
        self.listener.listen()
Exemplo n.º 2
0
 def querier(self):
     r = FifoListener('server_resp', self.handler)
     resp = Process(target = r.listen)
     resp.start()
     #await asyncio.sleep(2)
     self.start_time = time.time()
     for i in self.tasks:
         self.writer.write_to_stream(i)
Exemplo n.º 3
0
class Handle():
    def handler(self, content):
        self.respond(content)

    def __init__(self, filename, responder):
        self.filename = filename
        self.writer = FifoWriter('req_' + filename)
        self.reader = FifoListener('resp_' + filename, self.handler)
        self.responder = responder

    def start(self):
        self.reader.listen()

    def respond(self, content):
        self.responder.write_to_stream(content)

    def write(self, content):
        self.writer.write_to_stream(content)
Exemplo n.º 4
0
class DriverController():
    def __init__(self, dlist):
        self.handles = {}
        self.server = FifoListener('server_req', self.handler)
        responder = FifoWriter('server_resp')
        for i in dlist:
            self.handles[i[0]] = Handle(i[0], responder)

    def handler(self, inp):
        args = inp.split(';')
        self.handles[args[0]].write(" ".join(args[1:]))

    def listen(self):
        for i in self.handles:
            p = Process(target=self.handles[i].start)
            p.start()
        self.server.listen()

    def bad_handle(self, a, b):
        self.handles[a].write(b)
Exemplo n.º 5
0
def main():
    print('In main')
    listener = FifoListener("test", handler)

    a = Process(target=listener.listen)
    a.start()
    b = Process(target=test)
    b.start()
    print('here 2 ')
    bk = [a,b]
    print('here 3')

    for i in bk:
        i.join()
Exemplo n.º 6
0
 def querier(self):
     r = FifoListener('server_resp', self.handler)
     resp = Process(target=r.listen)
     resp.start()
Exemplo n.º 7
0
def test_listener():
    t_listener = FifoListener('resp_test', handler)
    t_listener.listen()
Exemplo n.º 8
0
 def __init__(self, driver_name):
     self.driver_name = driver_name
     self.listener = FifoListener('req_' + driver_name, self.def_handler)
     self.writer = FifoWriter('resp_' + driver_name)
Exemplo n.º 9
0
 def __init__(self, filename, responder):
     self.filename = filename
     self.writer = FifoWriter('req_' + filename)
     self.reader = FifoListener('resp_' + filename, self.handler)
     self.responder = responder
Exemplo n.º 10
0
 def __init__(self, dlist):
     self.handles = {}
     self.server = FifoListener('server_req', self.handler)
     responder = FifoWriter('server_resp')
     for i in dlist:
         self.handles[i[0]] = Handle(i[0], responder)