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 406 of file oauth_server.py.

406def main():
407 """
408 Starts the authorization server on localhost. The ephemeral port in use will
409 be printed to stdout.
410 """
411
412 s = http.server.HTTPServer(("127.0.0.1", 0), OAuthHandler)
413
414 # Attach a "cache" dictionary to the server to allow the OAuthHandlers to
415 # track state across token requests. The use of defaultdict ensures that new
416 # entries will be created automatically.
417 class _TokenState:
418 retries = 0
419 min_delay = None
420 last_try = None
421
422 s.token_state = defaultdict(_TokenState)
423
424 # Give the parent the port number to contact (this is also the signal that
425 # we're ready to receive requests).
426 port = s.socket.getsockname()[1]
427 print(port)
428
429 # stdout is closed to allow the parent to just "read to the end".
430 stdout = sys.stdout.fileno()
431 sys.stdout.close()
432 os.close(stdout)
433
434 s.serve_forever() # we expect our parent to send a termination signal
435
436
void print(const void *obj)
Definition: print.c:36

References main(), and print().

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