I have a simple Python program that queries a server via API. It uses the polygon-api-client module and returns stock market data in the form of a python list. The code is as follows: from polygon import RESTClient import confs import json ticker = 'AAPL' multiplier = 5 timeframe = 'minute' startdate = '2025-02-14' enddate = '2025-02-14' def createclient(): client = RESTClient(confs.API_KEY) aggs = client.get_aggs( ticker, multiplier, timeframe, startdate, enddate ) print(aggs) The code works, and in the terminal, I get a list of dictionaries. The issue is that theconnection doesnt close. Immediately following the list, I get the following message in the terminal: QSocketNotifier: Can only be used with threads started with QThread And then a blinking cursor (instead of a prompt for another command.) How can I close the connection from within my code so that it returns and I get a prompt in the terminal? Also, in case it helps, the polygon-api-client module depends on httpx and wsdump, so I assume that it uses one or both to create the web socket. Continue reading...