diff options
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | 2015-04-14 17:24:44 +0200 |
---|---|---|
committer | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | 2015-04-14 19:14:56 +0200 |
commit | c1f23b566b447dbaa4a4ea6942b61128b3161c10 (patch) | |
tree | 2b09723d1cf7bd8a545a9426fc4c727748648275 /slixmpp/plugins/xep_0047/ibb.py | |
parent | 45f7cb8bda42512bad70b6262483ac435209d9c3 (diff) | |
download | slixmpp-c1f23b566b447dbaa4a4ea6942b61128b3161c10.tar.gz slixmpp-c1f23b566b447dbaa4a4ea6942b61128b3161c10.tar.bz2 slixmpp-c1f23b566b447dbaa4a4ea6942b61128b3161c10.tar.xz slixmpp-c1f23b566b447dbaa4a4ea6942b61128b3161c10.zip |
XEP-0047: remove now-useless threading locks.
Diffstat (limited to 'slixmpp/plugins/xep_0047/ibb.py')
-rw-r--r-- | slixmpp/plugins/xep_0047/ibb.py | 33 |
1 files changed, 10 insertions, 23 deletions
diff --git a/slixmpp/plugins/xep_0047/ibb.py b/slixmpp/plugins/xep_0047/ibb.py index 87cd1f51..aa4e6afc 100644 --- a/slixmpp/plugins/xep_0047/ibb.py +++ b/slixmpp/plugins/xep_0047/ibb.py @@ -1,6 +1,5 @@ import uuid import logging -import threading from slixmpp import Message, Iq from slixmpp.exceptions import XMPPError @@ -30,10 +29,6 @@ class XEP_0047(BasePlugin): def plugin_init(self): self._streams = {} self._pending_streams = {} - self._pending_lock = threading.Lock() - self._stream_lock = threading.Lock() - - self._preauthed_sids_lock = threading.Lock() self._preauthed_sids = {} register_stanza_plugin(Iq, Open) @@ -85,9 +80,8 @@ class XEP_0047(BasePlugin): self._streams[(jid, sid, peer_jid)] = stream def _del_stream(self, jid, sid, peer_jid, data): - with self._stream_lock: - if (jid, sid, peer_jid) in self._streams: - del self._streams[(jid, sid, peer_jid)] + if (jid, sid, peer_jid) in self._streams: + del self._streams[(jid, sid, peer_jid)] def _accept_stream(self, iq): receiver = iq['to'] @@ -105,15 +99,13 @@ class XEP_0047(BasePlugin): return False def _authorized_sid(self, jid, sid, ifrom, iq): - with self._preauthed_sids_lock: - if (jid, sid, ifrom) in self._preauthed_sids: - del self._preauthed_sids[(jid, sid, ifrom)] - return True - return False + if (jid, sid, ifrom) in self._preauthed_sids: + del self._preauthed_sids[(jid, sid, ifrom)] + return True + return False def _preauthorize_sid(self, jid, sid, ifrom, data): - with self._preauthed_sids_lock: - self._preauthed_sids[(jid, sid, ifrom)] = True + self._preauthed_sids[(jid, sid, ifrom)] = True def open_stream(self, jid, block_size=None, sid=None, window=1, use_messages=False, ifrom=None, timeout=None, callback=None): @@ -134,9 +126,6 @@ class XEP_0047(BasePlugin): iq['from'], iq['to'], window, use_messages) - with self._stream_lock: - self._pending_streams[iq['id']] = stream - self._pending_streams[iq['id']] = stream cb = None @@ -151,8 +140,7 @@ class XEP_0047(BasePlugin): def _handle_opened_stream(self, iq): if iq['type'] == 'result': - with self._stream_lock: - stream = self._pending_streams.get(iq['id'], None) + stream = self._pending_streams.get(iq['id'], None) if stream is not None: log.debug('IBB stream (%s) accepted by %s', stream.sid, iq['from']) stream.self_jid = iq['to'] @@ -162,9 +150,8 @@ class XEP_0047(BasePlugin): self.xmpp.event('ibb_stream_start', stream) self.xmpp.event('stream:%s:%s' % (stream.sid, stream.peer_jid), stream) - with self._stream_lock: - if iq['id'] in self._pending_streams: - del self._pending_streams[iq['id']] + if iq['id'] in self._pending_streams: + del self._pending_streams[iq['id']] def _handle_open_request(self, iq): sid = iq['ibb_open']['sid'] |