code: def atexit_unregister(func, *args, **kwargs):
      
      try:
          atexit.unregister(func, *args, **kwargs)
      except AttributeError:
          # This code runs in Python 2.7 *only*
          # Only replace with a noop, don't delete during iteration
          for i in range(len(atexit._exithandlers)):
              if atexit._exithandlers[i] == (func, args, kwargs):
                  atexit._exithandlers[i] = (lambda: None, [], {})
                  break
docs: Python 2/3 compatible method for unregistering exit function.
  
      Python2 has no atexit.unregister function :/