简体   繁体   中英

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)
try:
    from queue import Queue
except ImportError:
    from Queue import Queue

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM