Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7620835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:02:30+00:00 2026-05-31T04:02:30+00:00

is this correct way of doing.i am a newbie python class main(threading.Thread): queueLock =

  • 0

is this correct way of doing.i am a newbie python

class main(threading.Thread):
    queueLock = threading.Lock()
    EppQueue = Queue.Queue(1)
    CrQueue = Queue.Queue(1)
    EPP = threading.Thread(name='EPP', target=EPP, args=(0,EppQueue,))
    cr = threading.Thread(name='cr', target=CR, args=(0,CrQueue,))
    EPP.setDaemon(True)
    EPP.start()
    Cr.start()
    self.send_queue("EppQueue","sss")
    self.send_queue("CrQueue","ssds")

    def send_queue(self,queuename,qvalue,b=None):
        if b is None:
            b = self.queuename
        self.queueLock.acquire()
        self.b.put(qvalue)
        self.queueLock.release()

when i run this i get NameError: name ‘self’ is not defined ???

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T04:02:31+00:00Added an answer on May 31, 2026 at 4:02 am

    The variable self (the first argument to a class method – you can use any name for it) is meant to refer to a class instance (also called an object). You use self where self is not defined, right out in the class where no specific object is yet known.

    When the code queueLock = threading.lock() … etc, is executed you are not in a class object (instance) but in the context of the class, so your lock will be the same for all objects of the class.

    About send_queue, it’s defined and known to all objects via the class, so you do not need to use self. to access it.

    If you want some code to be executed at instance creation put it in __init__.

    class main(threading.Thread):
      def __init__(self):
        self.queueLock = threading.Lock() 
        .. some code ... 
        send_queue("EppQueue","sss")
        send_queue("CrQueue","ssds")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is this the correct way to do it? <a id=load href=# class=btn load onclick=request(this);
I am not sure if this is the correct way of doing but I
I'm not sure if this is correct way of doing things but hopefully someone
I was just wondering if I'm doing this the correct way. I have 2
i know i have seen this but cant recall the correct way of doing
Is this the correct way to obtain the most negative double in Java? double
This is a simple question: Is this a correct way to get an integer
I'm not sure if this is the correct way to synchronize my ArrayList .
I'm still not sure this is the correct way to go about this, maybe
This may not be the correct way to use controllers, but I did notice

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.