sqs = boto3.client('sqs')response = sqs.receive_message(QueueUrl=queue_url,MaxNumberOfMessages=4)
You are not doing anything wrong, the behaviour is expected.
That is due to the distributed nature of SQS (and most AWS services). Basically not all nodes have all messages available and the node you talk to may return any number between 0 and MaxNumberOfMessages if any are available. To actually receive multiple message in a single call you need to have 100s or 1000+s of messages in the queue and even then you can be unlucky and receive very few messages.
From the docs:
If the number of messages in the queue is small (fewer than 1,000), you most likely get fewer messages than you requested per ReceiveMessage call. If the number of messages in the queue is extremely small, you might not receive any messages in a particular ReceiveMessage response. If this happens, repeat the request.