Never mind this request. I realized that for what I am doing, the web server 
was unnecessary. I could just load local HTML files directly into the 
QWebEngineView with no need of an intermediate server. Thanks anyway, and sorry 
for the noise!

---
Israel Brewster
Software Engineer
Alaska Volcano Observatory 
Geophysical Institute - UAF 
2156 Koyukuk Drive 
Fairbanks AK 99775-7320
Work: 907-474-5172
cell:  907-328-9145

> On Mar 13, 2019, at 1:42 PM, Israel Brewster <ijbrews...@alaska.edu> wrote:
> 
> I’m working on a Qt for python app that needs to run a local web server. For 
> the web server portion I’m using flask and uWISGI, and at the moment I have 
> my application launching uWISGI using subprocess before firing off the Qt 
> QApplication instance and entering the Qt event loop. Some sample code to 
> illustrate the process:
> 
> If __name__ ==“__main__”:
>     CUR_DIRECTORY = os.path.dirname(__file__)
> 
>     UWSGI_CONFIG = os.path.realpath(os.path.join(CUR_DIRECTORY, 'Other 
> Files/TROPOMI.ini'))
>     UWSGI_EXE = os.path.realpath(os.path.join(CUR_DIRECTORY, 'bin/uwsgi'))
>     uwsgi_proc = subprocess.Popen([UWSGI_EXE, UWSGI_CONFIG])
> 
>     qt_app = QApplication(sys.argv)
>     ….
>     res = qt_app.exec_()
> 
> 
> Now this works, but it strikes me as kinda kludgy, as the uWISGI is 
> effectively a separate application needed. More to the point, however, it’s a 
> bit fragile, in that if the main application crashes (really, ANY sort of 
> unclean exit), you get stray uWISGI processes hanging around that prevent 
> proper functioning of the app the next time you try to launch it. 
> Unfortunately as the app is still in early days, this happens occasionally. 
> So I have two questions:
> 
> 1) Is there a “better way”? This GitHub repo: 
> https://github.com/unbit/uwsgi-qtloop <https://github.com/unbit/uwsgi-qtloop> 
> seems to indicate that it should be possible to run a Qt event loop from 
> within a uWSGI app, thus eliminating the extra “subprocess” spinoff, but it 
> hasn’t been updated in 5 years and I have been unable to get it to work with 
> my current Qt/Python/OS setup
> 
> 2) Baring any “better way”, is there a way to at least ensure that the 
> subprocess is killed in the event of parent death, or alternately to look for 
> and kill any such lingering processes on application startup?
> 
> P.S. The purpose of running the web server is to be able to load and use 
> Plotly charts in my app (via a QWebEngineView). So a “better way” may be 
> using a different plotting library that can essentially “cut out” the middle 
> man. I’ve tried Matplotlib, but I found its performance to be worse than 
> Plotly - given the size of my data sets, performance matters. Also I had some 
> glitches with it when using a lasso selector (plot going black). Still, with 
> some work, it may be an option.
> 
> ---
> Israel Brewster
> Software Engineer
> Alaska Volcano Observatory 
> Geophysical Institute - UAF 
> 2156 Koyukuk Drive 
> Fairbanks AK 99775-7320
> Work: 907-474-5172
> cell:  907-328-9145
> 

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to