def set_shutdown_hook(hook):
 if ((hook is not None) and (not callable(hook))):
  raise TypeError(('hook must be callable, got %s' % hook.__class__))
 global __shutdown_hook
 with __shutdown_mutex:
  old_hook = __shutdown_hook
  __shutdown_hook = hook
 return old_hook

def set_shutdown_hook ( hook ) : if ( ( hook is not None ) and ( not callable ( hook ) ) ) : raise TypeError ( ( 'hook must be callable, got %s' % hook . __class__ ) ) global __shutdown_hook with __shutdown_mutex : old_hook = __shutdown_hook __shutdown_hook = hook return old_hook
registers a function to be called when the server is shutting down .