Road_House
Road_House

Reputation: 123

How to properly initialize a python queue?

I'm new to python and having trouble with the python queue, I'm initializing queue in my init constructor by when I run my python app it crashes, I've included a snippet of my code is there a better way to do it?

import os, sys
import time
if(sys.hexversion < 0x03000000):
  import Queue
else:
  import queue as Queue

class Appwindow():
  def __init__(self):
     self.myQueue = Queue.Queue()

  def displayMeth(self, stuff):
      if self.displayed:
         self.myQueue.put(stuff)

Upvotes: 0

Views: 3707

Answers (1)

LYF
LYF

Reputation: 40

try:
    from queue import Queue
except ImportError:
    from Queue import Queue

# shiny fancy Atomic Message Queue for concurrency
q = Queue()

Upvotes: 1

Related Questions