简体   繁体   中英

How to run multiprocessing code in wxPython app so it's non-blocking?

In my test I extract data from Oracle after user makes choice of tables from wxListCtrl. The problem is that long extract using multiprocessing module blocks wxPython UI. How to do it without blocking? Will it be pythonic to execute multiprocessing in threading.Thread?

You can let a pool run your processes or threads and you can give pool a max number of processes that it runs at one moment.

MaxProcessors = process.cpu_count()-1
self.pool = process.Pool(processes=min(NumberofProcess,MaxProcessors))

I use MaxProcessors to make sure there is always one core available for windows and the GUI.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM