So I'm trying to make a Webkit of sorts, however sometimes the pages stops to load(ideally I'd fix this problem, but can't seem to sort it out), so I've decided to come up with a hackish way of handling that issue. I want to close the current QWebEngineView then recreate it, this works as the view starts loading again, however it doesn't close itself properly. In task manager under processes i find several QtWebEngineProcess.exe processes if the program goes for a long time, which indicates that it isn't being closed properly. How if sip.delete(QWebEngineView) doesn't work what would help?
Qt Code:
  1. def _render(url, wait):
  2. try:
  3. from PyQt5.QtCore import QEventLoop, QUrl, QTimer
  4. from PyQt5.QtWebEngineWidgets import QWebEngineView
  5. from PyQt5.QtWidgets import QApplication
  6. from sip import delete
  7.  
  8. class Render():
  9. page_load_timeout = 15
  10.  
  11. def __init__(self, url, wait):
  12. self.url = QUrl(url)
  13. self.wait = wait
  14. self.html = None
  15. self.app = QApplication(sys.argv)
  16. self._createView()
  17. while self.html is None:
  18. self.app.processEvents(
  19. QEventLoop.ExcludeUserInputEvents |
  20. QEventLoop.ExcludeSocketNotifiers |
  21. QEventLoop.WaitForMoreEvents)
  22. self.app.quit()
  23.  
  24. def _createView(self):
  25. self.view = QWebEngineView()
  26. self.view.loadFinished.connect(self._loadFinished)
  27. self.view.loadProgress.connect(self._loadProgress)
  28. self.view.load(self.url)
  29.  
  30. def _checkProgress(self):
  31. cur = time.clock()
  32. if self._lastProg + self.page_load_timeout < cur:
  33. self._lastProg = time.clock()
  34. with open(os.getcwd() + "\\files\\wk_log.txt", "a") as f:
  35. f.write("Recreating view\n")
  36. delete(self.view)
  37. self._createView()
  38.  
  39. def _loadProgress(self, prog):
  40. with open(os.getcwd() + "\\files\\wk_log.txt", "a") as f:
  41. f.write("{}\n".format(prog))
  42. if prog != 100:
  43. self._lastProg = time.clock()
  44. QTimer.singleShot((self.page_load_timeout + 0.5) * 1000, self._checkProgress)
  45.  
  46.  
  47. def _loadFinished(self, result):
  48. QTimer.singleShot(self.wait * 1000, self._timer_for_html)
  49.  
  50. def _timer_for_html(self):
  51. self.view.page().toHtml(self._callable)
  52.  
  53. def _callable(self, data):
  54. self.html = data
  55. except:
  56. print("Exception occured")
  57.  
  58. #with devnull():
  59. return Render(url, wait).html
To copy to clipboard, switch view to plain text mode 
Never mind the layout of the code, it's just to get my problem across. The webview will load fine a couple of times, then suddenly break. Now the current code fixes this, however it doesn't close the previous view properly. I've thought about running del self.view However I don't think that would change anything as it would just delete the reference of the view and not the actual view itself.

Running PyQt5-5.8.2 on windows 10 64 bit, python 64 bit