mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-11-25 08:37:07 +01:00
use keepalive for connection pool
This commit is contained in:
parent
74283bd414
commit
6b457bada5
1 changed files with 10 additions and 4 deletions
|
@ -19,9 +19,11 @@
|
|||
"""This module contains methods to make POST and GET requests"""
|
||||
|
||||
import json
|
||||
import socket
|
||||
|
||||
import certifi
|
||||
import urllib3
|
||||
from urllib3.connection import HTTPConnection
|
||||
|
||||
from telegram import (InputFile, TelegramError)
|
||||
from telegram.error import Unauthorized, NetworkError, TimedOut, BadRequest
|
||||
|
@ -35,10 +37,14 @@ def _get_con_pool():
|
|||
return _CON_POOL
|
||||
|
||||
global _CON_POOL
|
||||
_CON_POOL = urllib3.HTTPSConnectionPool(host='api.telegram.org',
|
||||
maxsize=CON_POOL_SIZE,
|
||||
cert_reqs='CERT_REQUIRED',
|
||||
ca_certs=certifi.where())
|
||||
_CON_POOL = urllib3.HTTPSConnectionPool(
|
||||
host='api.telegram.org',
|
||||
maxsize=CON_POOL_SIZE,
|
||||
cert_reqs='CERT_REQUIRED',
|
||||
ca_certs=certifi.where(),
|
||||
socket_options=HTTPConnection.default_socket_options + [
|
||||
(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1),
|
||||
])
|
||||
return _CON_POOL
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue