mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-11-25 16:46:35 +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"""
|
"""This module contains methods to make POST and GET requests"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
import socket
|
||||||
|
|
||||||
import certifi
|
import certifi
|
||||||
import urllib3
|
import urllib3
|
||||||
|
from urllib3.connection import HTTPConnection
|
||||||
|
|
||||||
from telegram import (InputFile, TelegramError)
|
from telegram import (InputFile, TelegramError)
|
||||||
from telegram.error import Unauthorized, NetworkError, TimedOut, BadRequest
|
from telegram.error import Unauthorized, NetworkError, TimedOut, BadRequest
|
||||||
|
@ -35,10 +37,14 @@ def _get_con_pool():
|
||||||
return _CON_POOL
|
return _CON_POOL
|
||||||
|
|
||||||
global _CON_POOL
|
global _CON_POOL
|
||||||
_CON_POOL = urllib3.HTTPSConnectionPool(host='api.telegram.org',
|
_CON_POOL = urllib3.HTTPSConnectionPool(
|
||||||
maxsize=CON_POOL_SIZE,
|
host='api.telegram.org',
|
||||||
cert_reqs='CERT_REQUIRED',
|
maxsize=CON_POOL_SIZE,
|
||||||
ca_certs=certifi.where())
|
cert_reqs='CERT_REQUIRED',
|
||||||
|
ca_certs=certifi.where(),
|
||||||
|
socket_options=HTTPConnection.default_socket_options + [
|
||||||
|
(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1),
|
||||||
|
])
|
||||||
return _CON_POOL
|
return _CON_POOL
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue