May be the question is obscure. The example code below for clarify.
# file: sock.py
password = getpass.getpass("Password: ")
def run_socket_server():
with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as s:
# code...
if __name__ == "__main__":
run_socket_server()
Run the script
python sock.py
Password: # enter password
After this the process stay running not in background, blocking user input in terminal. So the question is how to continue to executing the python process in background to allow user input in terminal?