#1
  1. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    154

    Interger and Queue Problem


    Ok I'm having a serious problem with my queue because it won't let me use integers. Look at the following code:
    Code:
            if msg == "?trigger" and user == mt:
                triggeroccur = True
                print "Processing command..."
                log = open(date, 'a')
                log.write("Processing command...")
                q.append(curtr)
                if floodprotect1 == True:
                    delay = 4
                elif floodprotect1 = False:
                    if floodprotect2 == True:
                        delay = 5
                    elif floodprotect2 == False:
                        GetWait()
                    else:
                        pass
                else:
                    continue
                Queue()
                triggeroccur = False
    Most of that code you wont need to know what it does or what it's for. The line, q.append(curtr) adds curtr (it equals the current trigger, etc.) to the queue, making curtr equal [0] in the queue list. When the Queue starts, by doing the line, Queue(), heres what the code does,
    Code:
        def Queue():
            if len(queue[0]) >= 224:
                queue.pop([0])
            else:
               time.sleep(delay)
               data = queue[0]
               buffer = buffer + data + chr(0)
               BNETPacketId = 0x0E
               s.send(chr(0xFF) + chr(BNETPacketId) + struct.pack("< H", len(buffer) + 4) + buffer)
               Clear()
               queue.pop([0])
               print "Process complete!"
               log = open(date, 'a')
               log.write("Process complete!")
    I want the program to send each queue item 1 at a time and at the specified interval (delay). The problem I run into is that I don't know how to remove the item after it sends the item. queue.pop([0]) and queue.remove([0]) doesn't work. What else can I do?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Posts
    624
    Rep Power
    34
    If your queue is a Queue, then a lot of that code wont work, so I'll assume it's actually a list...

    Code:
    len(queue)
    
    and
    
    
    queue.pop(0)
    Last edited by sfb; December 20th, 2004 at 04:19 PM.

IMN logo majestic logo threadwatch logo seochat tools logo