#NEWLINE# @ web . authenticated #NEWLINE# def post( self , workername ) : #NEWLINE# #INDENT# '\nShrink worker\'s pool\n\n**Example request**:\n\n.. sourcecode:: http\n\n  POST /api/worker/pool/shrink/celery@worker2 HTTP/1.1\n  Content-Length: 0\n  Host: localhost:5555\n\n**Example response**:\n\n.. sourcecode:: http\n\n  HTTP/1.1 200 OK\n  Content-Length: 60\n  Content-Type: application/json; charset=UTF-8\n\n  {\n      "message": "Shrinking \'celery@worker2\' worker\'s pool by 1"\n  }\n\n:query n: number of pool processes to shrink, default is 1\n:reqheader Authorization: optional OAuth token to authenticate\n:statuscode 200: no error\n:statuscode 401: unauthorized request\n:statuscode 403: failed to shrink\n:statuscode 404: unknown worker\n        ' #NEWLINE# if ( not self . is_worker ( workername ) ) : #NEWLINE# #INDENT# raise web . HTTPError ( 404 , ( "Unknown worker '%s'" % workername ) ) #NEWLINE# #UNINDENT# n = self . get_argument ( 'n' , default = 1 , type = int ) #NEWLINE# logger . info ( "Shrinking '%s' worker's pool by '%s'" , workername , n ) #NEWLINE# response = self . capp . control . pool_shrink ( n = n , reply = True , destination = [ workername ] ) #NEWLINE# if ( response and ( 'ok' in response [ 0 ] [ workername ] ) ) : #NEWLINE# #INDENT# self . write ( dict ( message = ( "Shrinking '%s' worker's pool by %s" % ( workername , n ) ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# logger . error ( response ) #NEWLINE# self . set_status ( 403 ) #NEWLINE# self . write ( ( "Failed to shrink '%s' worker's pool: %s" % ( workername , self . error_reason ( workername , n ) ) ) )