mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-09 05:19:41 +00:00
Remove temporary connections and use a lock again
These seem to be the reason for missing some updates (#237)
This commit is contained in:
@@ -5,6 +5,7 @@ encrypting every packet, and relies on a valid AuthKey in the used Session.
|
||||
import gzip
|
||||
import logging
|
||||
import struct
|
||||
from threading import Lock
|
||||
|
||||
from .. import helpers as utils
|
||||
from ..crypto import AES
|
||||
@@ -53,6 +54,9 @@ class MtProtoSender:
|
||||
# Requests (as msg_id: Message) sent waiting to be received
|
||||
self._pending_receive = {}
|
||||
|
||||
# Multithreading
|
||||
self._send_lock = Lock()
|
||||
|
||||
def connect(self):
|
||||
"""Connects to the server."""
|
||||
self.connection.connect(self.session.server_address, self.session.port)
|
||||
@@ -71,10 +75,6 @@ class MtProtoSender:
|
||||
self._need_confirmation.clear()
|
||||
self._clear_all_pending()
|
||||
|
||||
def clone(self):
|
||||
"""Creates a copy of this MtProtoSender as a new connection."""
|
||||
return MtProtoSender(self.session, self.connection.clone())
|
||||
|
||||
# region Send and receive
|
||||
|
||||
def send(self, *requests):
|
||||
@@ -156,7 +156,8 @@ class MtProtoSender:
|
||||
|
||||
:param message: the TLMessage to be sent.
|
||||
"""
|
||||
self.connection.send(utils.pack_message(self.session, message))
|
||||
with self._send_lock:
|
||||
self.connection.send(utils.pack_message(self.session, message))
|
||||
|
||||
def _decode_msg(self, body):
|
||||
"""
|
||||
|
Reference in New Issue
Block a user