mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Issue #26404: Add context manager to socketserver, by Aviv Palivoda
This commit is contained in:
parent
7258176c68
commit
0cab9c1eba
11 changed files with 125 additions and 103 deletions
|
@ -971,16 +971,15 @@ if __name__ == '__main__':
|
|||
def getCurrentTime():
|
||||
return datetime.datetime.now()
|
||||
|
||||
server = SimpleXMLRPCServer(("localhost", 8000))
|
||||
server.register_function(pow)
|
||||
server.register_function(lambda x,y: x+y, 'add')
|
||||
server.register_instance(ExampleService(), allow_dotted_names=True)
|
||||
server.register_multicall_functions()
|
||||
print('Serving XML-RPC on localhost port 8000')
|
||||
print('It is advisable to run this example server within a secure, closed network.')
|
||||
try:
|
||||
server.serve_forever()
|
||||
except KeyboardInterrupt:
|
||||
print("\nKeyboard interrupt received, exiting.")
|
||||
server.server_close()
|
||||
sys.exit(0)
|
||||
with SimpleXMLRPCServer(("localhost", 8000)) as server:
|
||||
server.register_function(pow)
|
||||
server.register_function(lambda x,y: x+y, 'add')
|
||||
server.register_instance(ExampleService(), allow_dotted_names=True)
|
||||
server.register_multicall_functions()
|
||||
print('Serving XML-RPC on localhost port 8000')
|
||||
print('It is advisable to run this example server within a secure, closed network.')
|
||||
try:
|
||||
server.serve_forever()
|
||||
except KeyboardInterrupt:
|
||||
print("\nKeyboard interrupt received, exiting.")
|
||||
sys.exit(0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue