Python Forum
Screen printing on different threads
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Screen printing on different threads
#1
Hi folks.

In a multi threaded app, how can I assure one 'print' command completes with a carriage return before another thread butts in and prints data on the same line?

I have a central report def which I use to format and print data in the main file, but there are other files/scripts that are called on new threads.

Do I need a reporting script that all other modules/files/scripts use?

Thanks.
Reply
#2
Quote:I have a central report def which I use to format and print data in the main file, but there are other files/scripts that are called on new threads.

Since all your threads are writing to the same file; you may need locking mechanism to serialise the process. I would open the file once, and hold on to the file handler in a global variable, and use thread locks to access the file handler.

Does that makes sense?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  wn = turtle.screen() AttributeError: module 'turtle' has no attribute 'screen' Shadower 1 6,191 Feb-06-2019, 01:25 AM
Last Post: woooee
  Output not printing when execute scripts in threads anna 1 2,747 Mar-21-2018, 05:08 PM
Last Post: woooee
  printing to a printer vs the screen birdieman 4 5,706 Dec-27-2016, 07:32 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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