Python Forum
name a thread defined from a class
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
name a thread defined from a class
#1
hi

i have a class using a thread as object

how can i give him a name. it will help the debugging in pycharm

temp.py
class WTemp(threading.Thread):

    def __init__(self, sleep):
        threading.Thread.__init__(self)
        self.sleep = sleep
        self.W_temp = 0

    def run(self):
        while True:
            # reads every sleep interval >0.8 (sensor response minimum delay)
            self.W_temp = W1ThermSensor().get_temperature()
            time.sleep(self.sleep)

    def read_temp(self):
        water_temp = self.W_temp
  
main.py
from temp import Wtemp

Wtemp.start()
how do i give a name to the thread .
in pycharm it appears has Thread7

thanks
Reply
#2
no solutions?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  "Name is not defined" when running a class lil_e 6 3,765 Jan-12-2023, 11:57 PM
Last Post: lil_e
  Why built in functions are defined as class? quazirfan 5 2,714 Oct-23-2021, 01:20 PM
Last Post: Gribouillis
  Error when refering to class defined in 'main' in an imported module HeRo 2 2,331 Apr-13-2021, 07:22 PM
Last Post: HeRo
  "Class already defined" while using typings. DreamingInsanity 0 2,302 Aug-19-2020, 10:43 AM
Last Post: DreamingInsanity
  python library not defined in user defined function johnEmScott 2 3,773 May-30-2020, 04:14 AM
Last Post: DT2000
  Error SQLite objects created in a thread can only be used in that same thread. binhduonggttn 3 15,389 Jan-31-2020, 11:08 AM
Last Post: DeaD_EyE
  Python complains that class instance is not defined colt 3 5,543 Sep-17-2019, 12:32 AM
Last Post: ichabod801
  saving (in text or binary) an object under a defined class cai0824 3 3,036 May-12-2019, 08:55 AM
Last Post: snippsat
  "not defined" error in function referencing a class Exsul 2 3,639 Mar-27-2019, 11:59 PM
Last Post: Exsul
  Creating class - name not defined error python_alex 3 16,081 Jun-30-2018, 11:17 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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