Hey. There is a flask that communicates with the browser via http. For some reason, sometimes, after running Ctrl + C, it turns out that I still have a hanging connection, but no process is associated with it. Therefore, I can not reconnect to the browser, as this port and address are busy. How to kill a connection under Ubuntu 16.04?
This is what netstat produces:
$ netstat -na | grep :8080 tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN Here is an example of the server code:
from flask import Flask, request import json import requests app = Flask(__name__) @app.route('/search/3', methods=['GET', 'POST']) def GetFromBrowser(): if request.method == 'GET': try: connection = requests.get("http://localhost:8082/search/3", params = request.args) except: print("python: Unexpected connection") return "" # ... return connection.text else: return "" if __name__ == '__main__': app.run(host = '127.0.0.1', port = '8080')