LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 01-15-2008, 03:14 PM   #1
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Rep: Reputation: 51
python thread safety: printing from thread to redirected stdout - safe?


This is actually a wxPython GUI question, but may still fall under the generic python umbrella.

If I redirect stdout (which, in my case, will update a wxPython text control), then run a print command from a thread. The thread updates the GUI via print. Is this safe or should I communicate via thread & main & let main handle it?
 
Old 10-11-2010, 03:33 AM   #2
ToothlessRebel
Member
 
Registered: Jun 2004
Location: FL, USA
Distribution: Slackware 9.1
Posts: 190

Rep: Reputation: 30
I believe it is commonly recommended to never update the GUI through a thread, always the main.
 
Old 10-11-2010, 11:28 AM   #3
bgeddy
Senior Member
 
Registered: Sep 2006
Location: Liverpool - England
Distribution: slackware64 13.37 and -current, Dragonfly BSD
Posts: 1,810

Rep: Reputation: 227Reputation: 227Reputation: 227
Have a look at wxAnyThread which is in the PyPI and looks useful. Note this quoted from the module :
Quote:
In wxPython, methods that alter the state of the GUI are only safe to call from the thread running the main event loop. Other threads must typically post events to the GUI thread instead of invoking methods directly.
I've not used the module myself, or indeed wxpython very much so can't comment on the quality.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Thread-safe global variables in C JoeyAdams Programming 12 06-20-2012 08:52 PM
is Pam Thread Safe??? ptobra Programming 4 07-24-2007 09:19 PM
Thread safety jkoshi Linux - Software 3 05-03-2007 01:03 PM
What is thread safe....??? rajsun Programming 5 04-26-2005 11:33 PM
Thread Safety on PHP Gerardoj Linux - General 2 03-28-2004 06:22 AM


All times are GMT -5. The time now is 07:03 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration