-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow ctrl-c to be processed when establishing connection #64
Comments
Could you share your code? Did you add a keyboard interrupt catch and it wasn't triggered? https://docs.python.org/3/library/exceptions.html#KeyboardInterrupt |
Sure! Here's my code. import openziti
from http.server import BaseHTTPRequestHandler, HTTPServer
# constants
hostname = "127.0.0.1"
port = "12345"
ziti_config = dict(
ztx="./identity.json",
service="python-sdk-server"
)
openziti.monkeypatch(bindings={(hostname, port): ziti_config})
class MyZitiServer(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header('Content-Type', 'text/html')
self.end_headers()
self.wfile.write("<h1>Hello from OpenZiti Python SDK</h1>".encode("utf-8"))
if __name__ == "__main__":
server = HTTPServer((hostname, port), MyZitiServer)
print(f"Server running on {hostname}:{port}...")
try:
server.serve_forever(poll_interval=600)
except KeyboardInterrupt:
server.server_close()
print("Server is closing...") I also tried the http server example and ctrl-c also didn't work when the library was retrying to connect to my ziti network. The "Server running" line didn't even print so I suspect it's something happening and stuck in the |
can you set |
Sure here's the log https://gist.github.com/nickchen120235/33122b637a4c43472517a8d428626b7d Note that I purposefully make the edge router not available to the service so that the sdk will try to connect before the Python server is actually started. |
Version Information
openziti
SDK: 0.8.1Current Behavior
Ctrl-C is ignored (maybe?) when the module is trying to establish connection to the ziti network. Today I was playing with the Python SDK and forgot to configure router policy for my identity for the service. I recognized my error when running the script with
ZITI_LOG=6
but I cannot Ctrl-C to stop the script.Expected Behavior
I can stop the script by Ctrl-C even if the script is trying something in the library.
The text was updated successfully, but these errors were encountered: