Search code examples
pythonpython-3.xexceptionasserteventlet

Eventlet assert exception on queue.put


I'm getting weird exception from time to time when trying to put in eventlet/queue some item.

for message in kafka_consumer:
    queue_in.put(message.value)

packages/eventlet/queue.py", line 265, in put
  assert result is waiter, "Invalid switch into Queue.put: %r" % (result, )
AssertionError: Invalid switch into Queue.put: ([16], [], [])

Any idea what could be the reason for it?

Thanks.


Solution

  • The solution I've found to this was adding eventlet.sleep() after:

    queue.put(event)
    eventlet.sleep()
    

    Hope it will help anyone.