PostgreSQL Source Code git master
oauth_server Namespace Reference

Data Structures

class  OAuthHandler
 

Functions

def main ()
 

Function Documentation

◆ main()

def oauth_server.main ( void  )
Starts the authorization server on localhost. The ephemeral port in use will
be printed to stdout.

Definition at line 367 of file oauth_server.py.

367def main():
368 """
369 Starts the authorization server on localhost. The ephemeral port in use will
370 be printed to stdout.
371 """
372
373 s = http.server.HTTPServer(("127.0.0.1", 0), OAuthHandler)
374
375 # Attach a "cache" dictionary to the server to allow the OAuthHandlers to
376 # track state across token requests. The use of defaultdict ensures that new
377 # entries will be created automatically.
378 class _TokenState:
379 retries = 0
380 min_delay = None
381 last_try = None
382
383 s.token_state = defaultdict(_TokenState)
384
385 # Give the parent the port number to contact (this is also the signal that
386 # we're ready to receive requests).
387 port = s.socket.getsockname()[1]
388 print(port)
389
390 # stdout is closed to allow the parent to just "read to the end".
391 stdout = sys.stdout.fileno()
392 sys.stdout.close()
393 os.close(stdout)
394
395 s.serve_forever() # we expect our parent to send a termination signal
396
397
void print(const void *obj)
Definition: print.c:36

References main(), and print().

Referenced by oauth_server.OAuthHandler._token_state(), and main().