Open nickchen120235 opened 2 months ago
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 openziti.monkeypatch
line.
can you set ZITI_LOG=4
environment variable and post/send the output?
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.