def _cache_server_process(queue, return_failed, cache_root):
 httpd = None
 try:
  with temporary_dir() as tmpdir:
   cache_root = (cache_root if cache_root else tmpdir)
   with pushd(cache_root):
    if return_failed:
     handler = FailRESTHandler
    else:
     handler = SimpleRESTHandler
    httpd = SocketServer.TCPServer((u'localhost', 0), handler)
    port = httpd.server_address[1]
    queue.put(port)
    httpd.serve_forever()
 finally:
  if httpd:
   httpd.shutdown()

def _cache_server_process ( queue , return_failed , cache_root ) : httpd = None try : with temporary_dir ( ) as tmpdir : cache_root = ( cache_root if cache_root else tmpdir ) with pushd ( cache_root ) : if return_failed : handler = FailRESTHandler else : handler = SimpleRESTHandler httpd = SocketServer . TCPServer ( ( u'localhost' , 0 ) , handler ) port = httpd . server_address [ 1 ] queue . put ( port ) httpd . serve_forever ( ) finally : if httpd : httpd . shutdown ( )
a pickleable top-level function to wrap a simpleresthandler .