Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cherrypy and wxpython

I'm trying to make a cherrypy application with a wxpython ui. The problem is both libraries use closed loop event handlers. Is there a way for this to work? If I have the wx ui start cherrypy is that going to lock up the ui?

like image 207
tehryan Avatar asked Jan 07 '10 17:01

tehryan


3 Answers

See my answer at CherryPy interferes with Twisted shutting down on Windows

In short, CherryPy handles the main loop by default, but it definitely doesn't need to. Stop using quickstart and call engine.start without engine.block, and CP will run in its own threads and leave the main thread for your other framework to control.

like image 85
fumanchu Avatar answered Sep 26 '22 09:09

fumanchu


If you use threading, you should be able to start up the CherryPy server in one thread and run wxPython in the other. This article (http://wiki.wxpython.org/LongRunningTasks) on the wxPython wiki has some info on threading, and the CherryPy server source code (http://www.cherrypy.org/browser/trunk/cherrypy/wsgiserver/__init__.py) has some documentation on how the server works, and possibly how you could get it to interact with threads.

like image 44
LeafStorm Avatar answered Sep 26 '22 09:09

LeafStorm


One way to decouple them would be to start them up as two separate processes and have them communicate via some kind of IPC mechanism. You might have to write a small adaptor to have them speak a common protocol.

Since you're doing CherryPy, you might also be able to expose a control interface via HTTP which the wx GUI can use to drive your server.

like image 25
Noufal Ibrahim Avatar answered Sep 25 '22 09:09

Noufal Ibrahim