Skip to content

urllib + MessageQueue = Connection pool is full warning #787

@korcky

Description

@korcky

Steps to reproduce

  1. Create bot with implementation of MessageQueue (and add logging)
  2. Add simply handler for him
  3. Send something to him

Code example:

import logging
import telegram.bot
from telegram.ext import messagequeue as mqueue
from telegram.ext import Updater, RegexHandler

logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
                    level=logging.INFO)
logger = logging.getLogger(__name__)

TOKEN = ''


class MQBot(telegram.bot.Bot):
    def __init__(self, *args, is_queued_def=True, msg_queue=None, **kwargs):
        super().__init__(*args, **kwargs)
        # For decorator usage
        self._is_messages_queued_default = is_queued_def
        self._msg_queue = msg_queue or mqueue.MessageQueue()

    @mqueue.queuedmessage
    def send_message(self, *args, **kwargs):
        super().send_message(*args, **kwargs)


def start(bot, update):
    update.message.reply_text('start')

if __name__ == '__main__':
    msg_queue = mqueue.MessageQueue(all_burst_limit=29, all_time_limit_ms=1017)
    bot = MQBot(TOKEN, msg_queue=msg_queue)
    updater = Updater(bot=bot)
    dispatcher = updater.dispatcher

    dispatcher.add_handler(RegexHandler('\w*', start))

    updater.start_polling()
    updater.idle()

Expected behaviour

No errors/warnings should appears.

Actual behaviour

In logs appears warning:
telegram.vendor.ptb_urllib3.urllib3.connectionpool - WARNING - Connection pool is full, discarding connection: api.telegram.org

Mb the problem is because of this (maxsize=1)

Configuration

Version of Python, python-telegram-bot & dependencies:

python-telegram-bot 7.0.1
certifi 2017.07.27.1
future 0.16.0
Python 3.5.2 (default, Nov 17 2016, 17:05:23)  [GCC 5.4.0 20160609]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy