Python doesn't throw an error because lines 99-123 are only executed when the long polling ajax request is received after a file is opened with handle_rest_file(), in which last_atime is initialized. Commit bb9e4ae now pre-sets it at the module level.

As for the global variable, its purpose is to ensure only one long polling request is active at a time, which is essentially a hack until someone finds a way to keep BaseHTTPServer from flushing every pending response when a new request is received, leading to the looping behaviour described above.