Skip to content
Newer
Older
100644 27 lines (18 sloc) 651 Bytes
009ca2f @tkf Move echo server to examples/echo/server.py
authored
1 import logging
2
3 from epc.server import EPCServer
4
5
6 def echo_server(address='localhost', port=0, logfilename='python-epc.log'):
b99b82e @tkf Set log_traceback=True in examples
authored
7 server = EPCServer((address, port), log_traceback=True)
009ca2f @tkf Move echo server to examples/echo/server.py
authored
8 server.logger.setLevel(logging.DEBUG)
9
10 ch = logging.FileHandler(filename=logfilename, mode='w')
11 ch.setLevel(logging.DEBUG)
12 server.logger.addHandler(ch)
13
14 def echo(*a):
15 """Return argument unchanged."""
16 return a
17 server.register_function(echo)
18 return server
19
20
21 if __name__ == '__main__':
22 server = echo_server()
23 server.print_port() # needed for Emacs client
24
25 server.serve_forever()
26 server.logger.info('exit')
Something went wrong with that request. Please try again.