Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Worker thread?
#1
My program does the following:
SQL query results based on GUI (user filled) data is passed to TCPprinter thread in arguments. I'm using threading because I need to check printer(s) state and don't want to freeze the GUI. However GUI will only show status info until the TCPprinter thread is finished. After that user is allowed to enter new data and start printing thread again.

Should I use queue instead and keep my TCPprinter thread running as long as GUI is alive, or is there some better approach?
Reply
#2
Your GUI thread would have to polls some common variable, but polling is not possible in a GUI (unless you have a manual "refresh" button). The other (and most common) solution is to have the printer thread notify the GUI thread. But this requires the printer thread to be able to send some event to the GUI even loop. Most GUI libraries support this, except tkinter...
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Suspending worker threads olderguy 1 2,039 Apr-21-2021, 10:28 AM
Last Post: Larz60+
  Error SQLite objects created in a thread can only be used in that same thread. binhduonggttn 3 15,604 Jan-31-2020, 11:08 AM
Last Post: DeaD_EyE
  Receive data from Redis RQ worker process freak14 0 1,908 Jul-15-2019, 12:39 PM
Last Post: freak14
  Sending a custom signal from a worker mhc 4 4,804 Jul-03-2018, 04:05 PM
Last Post: mhc
  Good way to have a worker queue accessible by multiple process? cheater 2 2,514 Dec-21-2017, 09:30 PM
Last Post: wavic

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020