pika: IndexError: pop from an empty deque

here is the bug report

QUANTAXIS>> _AsyncBaseTransport._produce() failed, aborting connection: error=IndexError('pop from an empty deque',); sock=<socket.socket fd=2044, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_STREAM, proto=6, laddr=('::1', 3520, 0, 0), raddr=('::1', 5672, 0, 0)>; Caller's stack:
Traceback (most recent call last):
  File "e:\pika\pika\adapters\utils\io_services_utils.py", line 1092, in _on_socket_writable
    self._produce()
  File "e:\pika\pika\adapters\utils\io_services_utils.py", line 817, in _produce
    chunk = self._tx_buffers.popleft()
IndexError: pop from an empty deque
Traceback (most recent call last):
  File "e:\pika\pika\adapters\utils\io_services_utils.py", line 1092, in _on_socket_writable
    self._produce()
  File "e:\pika\pika\adapters\utils\io_services_utils.py", line 817, in _produce
    chunk = self._tx_buffers.popleft()
IndexError: pop from an empty deque
QUANTAXIS>> _AsyncTransportBase._initate_abort(): Initiating abrupt asynchronous transport shutdown: state=1; error=IndexError('pop from an empty deque',); <socket.socket fd=2044, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_STREAM, proto=6, laddr=('::1', 3520, 0, 0), raddr=('::1', 5672, 0, 0)>
QUANTAXIS>> Deactivating transport: state=1; <socket.socket fd=2044, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_STREAM, proto=6, laddr=('::1', 3520, 0, 0), raddr=('::1', 5672, 0, 0)>
QUANTAXIS>> connection_lost: StreamLostError: ("Stream connection lost: IndexError('pop from an empty deque',)",)
QUANTAXIS>> AMQP stack terminated, failed to connect, or aborted: error-arg=StreamLostError: ("Stream connection lost: IndexError('pop from an empty deque',)",); pending-error=None
QUANTAXIS>> Stack terminated due to StreamLostError: ("Stream connection lost: IndexError('pop from an empty deque',)",)
QUANTAXIS>> Closing transport socket and unlinking: state=2; <socket.socket fd=2044, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_STREAM, proto=6, laddr=('::1', 3520, 0, 0), raddr=('::1', 5672, 0, 0)>
QUANTAXIS>> Unexpected connection close detected: StreamLostError: ("Stream connection lost: IndexError('pop from an empty deque',)",)
Stream connection lost: IndexError('pop from an empty deque',)
QUANTAXIS>> BlockingConnection.close(200, 'Normal shutdown') called on closed connection.
QUANTAXIS>> [QUANTAXIS REALTIME] connecting to ('::1', 5672, 0, 0)


About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 20 (8 by maintainers)

Commits related to this issue

Most upvoted comments

@yutiansut @lukebakken Is this issue solved? In my case, the exception occured when the pika connection was shared across threads, which should have been avoided.

@splusz I could never reproduce it. Hey. I know how to reproduce it …but by my way.

def kidok():
    while True:
        channel.queue_declare(queue='TG.send.msg.rq')
        data = sql.get_users_list()
        print(data)
        time.sleep(30)

thread1 = threading.Thread(target=kidok)
thread1.start()
q1 = channel.queue_declare(queue='VK.add.new.user.rq')

and I solved it when I created a new channel and connection:

def kidok():
    connection2 = pika.BlockingConnection(parameters)
    channel2 = connection2.channel()
    while True:
        channel2.queue_declare(queue='TG.send.msg.rq')
        data = sql.get_users_list()
        print(data)
        time.sleep(30)

thread1 = threading.Thread(target=kidok)
thread1.start()

q1 = channel.queue_declare(queue='VK.add.new.user.rq')

hope it helps.

I solved my problem following this pika example, specifically using connection.add_callback_threadsafe(cb).

This allows to share a connection through threads.